To all html & css lovers. We made this UI Library for you :)

We announced Frontendor.com HTML blocks & templates library last days after we focused on three essentials gaols:

✦ Neat code, easy to customize
✦ Separate blocks, easy to integrate
✦ Create landing pages by COPY-PASTE.

This way, we can build a new landing page every time just by copying the HTML & CSS from our library.

We would love to hear your very honest feedback and suggestion. Thank you.

PS: If you liked Frontendor and want to support us. You can grab your deal with…

To all html & css lovers. We made this UI Library for you :)

What is the possible character set for the jsonwebtoken nodejs library?

I see a lot of folks using the following for a private key when using the jsonwebtoken library:

const hexStr = require('crypto').randomBytes(64).toString('hex') 

But this returns a character set of only 0-9 and a-f. Not a good practice it seems.

jwt.sign({ name: kennedy }, hexStr); 

However this approach is seeming a much better, more secure approach as now we’re using the full character set as binary data:

jwt.sign({ name: kennedy }, Buffer.from(hexStr, 'hex').toString()) 

Thoughts on this? Is the second approach a better one? I’m just looking for affirmation (or not!) that I’m doing it correctly.

Independent C library or function (on Linux) to programmatically generate a self-signed certificate [closed]

Is there a simple C library or function to programmatically generate a self-signed certificate in C on Ubuntu? Of course, one can execute a simple system("....") call to execute a CLI. I am looking for a native, small, stand-alone library just for this purpose with possibly added functionality but not with the full-weight of TLS implementations such as openssl, boringssl, mbedTls, etc.

Merge Multisites with Shared Network Media Library

So have a multisite setup which no longer needs to be a multisite but I’m left with a bit of a mess since I used Network Media Library plugin to host images for all sites on the network. I’ll try to break it down:

  • started out with WP multisite
  • created two sites on the network
  • installed Network Media Library
  • site #1 hosted the media library
  • both sites hosted posts
  • (about a year and a lot of posting goes by)
  • pulled site #1 out of multisite to be hosted independently
  • left with multisite running site #2 but still pulling it’s media from site #1

What I want to do now is combine site #2 which contains all my posts with site #1 which contains only media. My concerns are:

  • if I merge tables there will be ID conflicts (some posts will have same ID as attachments)
  • if I use import function to bring images into posts site then images will be given new IDs and post thumbnail relations will all break
  • if I use import function to bring posts into images site then post IDs would change which can’t happen because we use the ID in the post URL

The best idea I have so far is to somehow…

  • use the WordPress import function to import all the attachments into the posts site
  • log old and new IDs into a new table in the DB as the process works
  • then iterate over all the posts switching old for new IDs in the post_meta _thumbnail_id fields
  • ideally then be left with one site which contains all the posts and attachments so I can reduce the install down to regular non-multisite.

There’s tens of thousands of posts on these combined sites so performing these functions is no small feat and really not sure where to start so I wonder if anyone has any experience of a process like this or ideas for alternative solutions.

Thanks for reading.

I am trying to configure CSRFGuard library in my java web application, however i get the following error

I have included the csrf 3.0 jar and also included the at the beginning of the jsp pages. However, i get the error when i try to run my project.Can someone guide me to implement CSRF Guard properly on my web application. Thanks for your help.

<java.lang.NoSuchMethodError: org.owasp.csrfguard.CsrfGuard.load(Ljava/util/Properties;)V         at org.owasp.csrfguard.CsrfGuardServletContextListener.contextInitialized(CsrfGuardServletContextListener.java:38)         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4732)         at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5194)         at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)         at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596)         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:467)         at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1617)         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.lang.reflect.Method.invoke(Method.java:606)         at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)         at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)         at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1483)         at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:904)         at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:336)         at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)         at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)         at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)         at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:632)         at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:318)         at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:97)         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)         at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)         at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1096)         at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)         at org.apache.coyote.AbstractProtocol$  ConnectionHandler.process(AbstractProtocol.java:760)         at org.apache.tomcat.util.net.NioEndpoint$  SocketProcessor.run(NioEndpoint.java:1480)         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)         at java.util.concurrent.ThreadPoolExecutor$  Worker.run(ThreadPoolExecutor.java:615)         at org.apache.tomcat.util.threads.TaskThread$  WrappingRunnable.run(TaskThread.java:61)         at java.lang.Thread.run(Thread.java:745) 

Below is the web.xml configuration. I have included CSRFGuard 3.0 jar

    <listener>         <listener-class>org.owasp.csrfguard.CsrfGuardServletContextListener</listener-class>     </listener>       <listener>         <listener-class>org.owasp.csrfguard.CsrfGuardHttpSessionListener</listener-class>     </listener>      <filter>         <filter-name>CSRFGuard</filter-name>         <filter-class>org.owasp.csrfguard.CsrfGuardFilter</filter-class>         <init-param>             <param-name>error_page</param-name>             <param-value>/csrfAttackError.jsp</param-value>          </init-param>     </filter>     <context-param>         <param-name>Owasp.CsrfGuard.Config</param-name>         <param-value>WEB-INF/Owasp.CsrfGuard.properties</param-value>     </context-param>     <context-param>         <param-name>Owasp.CsrfGuard.Config.Print</param-name>         <param-value>false</param-value>     </context-param>     <listener>         <listener-class>org.owasp.csrfguard.CsrfGuardListener</listener-class>     </listener>   <servlet>     <servlet-name>JavaScriptServlet</servlet-name>     <servlet-class>org.owasp.csrfguard.servlet.JavaScriptServlet</servlet-class>      <init-param>         <param-name>source-file</param-name>         <param-value>WEB-INF/Owasp.CsrfGuard.js</param-value>     </init-param>     <init-param>         <param-name>inject-into-forms</param-name>         <param-value>true</param-value>     </init-param>     <init-param>         <param-name>inject-into-attributes</param-name>         <param-value>true</param-value>     </init-param>     <init-param>         <param-name>domain-strict</param-name>         <param-value>false</param-value>     </init-param>     <init-param>         <param-name>referer-pattern</param-name>         <param-value>.*</param-value>     </init-param> </servlet> 

How to show demo wordpress websites like themeforest or elementor library?

Suppose I’ve 10+ WordPress themes to sell, Now I want the user to click on the theme image to open a preview of the theme just like ThemeForest or elementor library. Should I create 10+ directories and install WordPress for each theme?

Please checkout elementor templates library https://library.elementor.com/ for a better idea

Thanks a lot for your response.

Is there any hash library with 3 wise independent hash functions in python

So I was looking for a hash family with 3 wise independent hash functions and I know the theory behind it and coding it is not super difficult but I actually need very good accuracy. So it would be actually nice if I could use a library which is already defined in python. Is there any such library with 3 wise independent hash functions? I googled it but didn’t get any proper answer.

Text Rendering using FreeType library not working correctly

Currently I am implementing text rendering into my game engine using the FreeType library by following the tutorial found here: https://learnopengl.com/In-Practice/2D-Game/Render-text. My current implementation is not working correctly, you can see the result of my implementation in the following Images (note that I am rendering the text “Test test”, and you can see 8 distinct cubic shapes one for each letter with a space in between the words, with the last 4 cubic shapes being smaller and shaped differently compared to the capitalized version of the word, so it looks like it is at least close to rendering the string “Test test”):

enter image description here

enter image description here

Firstly, there are some obvious issues, to start with you can see the “text” is drawn in a projection perspective rather than orthographic, this is on purpose however because my system already draws with projection perspective and if the text was stuck flat to my screen in a 2D manner I fail to see how the perspective it is drawn in would change anything.

That leads to the next problem, the “text” is not stuck to my screen in a 2D manner (like HUD elements in a game), it appears to be floating in 3D space, although if I look at the “Text” from exactly side on it will vanish, so it does not appear to have any depth (z axis), only a position on the x and y axis. Also if I go past the side on point and look from behind the “text” vanishes.

And finally the most obvious issue, the glyphs clearly are not rendered correctly, as you cant see the actual shape of the letters, instead just the cubic space containing the letter.

My implementation is as follows: (disclaimer: My engine is to big to explain every little thing that is going on so this question is showing minimal code and only relevant code to this issue, described in quite a high level manner)

In my engine the scene is created using a scene graph of GameObject‘s each with GameComponent‘s, therefore I create a TextRendererObject and add to it a TextRenderer component and add it to the scene in the following code:

Entity *textRendererObject = new Entity(...); TextRenderer  *Text; Text = new TextRenderer(50, 50); Text->Load("font/arial.ttf", 240); textRendererObject->AddComponent(Text); AddToScene(textRendererObject); 

The TextRenderer constructor, a struct that the .h file defines (used in load function) and the load function are as follows respectively:

TextRenderer::TextRenderer(GLuint width, GLuint height) :     TextShader("text")//creates text shader (text.glsl) {    GLuint VAO, VBO;      SetIsTextRenderer(true);      glGenVertexArrays(1, &this->VAO);     glGenBuffers(1, &this->VBO);     glBindVertexArray(this->VAO);     glBindBuffer(GL_ARRAY_BUFFER, this->VBO);     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW);     glEnableVertexAttribArray(0);     glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0);     glBindBuffer(GL_ARRAY_BUFFER, 0);     glBindVertexArray(0); } 
/// Holds all state information relevant to a character as loaded using FreeType struct Character {     GLuint TextureID;   // ID handle of the glyph texture     glm::ivec2 Size;    // Size of glyph     glm::ivec2 Bearing; // Offset from baseline to left/top of glyph     GLuint Advance;     // Horizontal offset to advance to next glyph }; //... std::map<GLchar, Character> Characters; 
void TextRenderer::Load(std::string font, GLuint fontSize) {     // First clear the previously loaded Characters     this->Characters.clear();     // Then initialize and load the FreeType library     FT_Library ft;     if (FT_Init_FreeType(&ft)) // All functions return a value different than 0 whenever an error occurred         printf("ERROR::FREETYPE: Could not init FreeType Library");//std::cout << "ERROR::FREETYPE: Could not init FreeType Library" << std::endl;     // Load font as face     FT_Face face;     if (FT_New_Face(ft, font.c_str(), 0, &face))         printf("ERROR::FREETYPE: Failed to load font");//std::cout << "ERROR::FREETYPE: Failed to load font" << std::endl;     // Set size to load glyphs as     FT_Set_Pixel_Sizes(face, 0, fontSize);     // Disable byte-alignment restriction     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);     // Then for the first 128 ASCII characters, pre-load/compile their characters and store them     for (GLubyte c = 0; c < 128; c++)       {         // Load character glyph          if (FT_Load_Char(face, c, FT_LOAD_RENDER))         {             printf("ERROR::FREETYTPE: Failed to load Glyph");//std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;             continue;         }         // Generate texture         GLuint texture;         glGenTextures(1, &texture);         glBindTexture(GL_TEXTURE_2D, texture);         glTexImage2D(             GL_TEXTURE_2D,             0,             GL_RED,             face->glyph->bitmap.width,             face->glyph->bitmap.rows,             0,             GL_RED,             GL_UNSIGNED_BYTE,             face->glyph->bitmap.buffer         );         // Set texture options         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);          // Now store character for later use         Character character = {             texture,             glm::ivec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),             glm::ivec2(face->glyph->bitmap_left, face->glyph->bitmap_top),             face->glyph->advance.x         };         Characters.insert(std::pair<GLchar, Character>(c, character));     }     glBindTexture(GL_TEXTURE_2D, 0);     // Destroy FreeType once we're finished     FT_Done_Face(face);     FT_Done_FreeType(ft); } 

The shader (text.glsl) that is created when the Textrenderer object is created is as follows:

#include "common.glh"  varying vec2 texCoord0; varying vec3 worldPos0;  #if defined(VS_BUILD) attribute vec3 position; attribute vec2 texCoord;  uniform mat4 T_model; uniform mat4 T_MVP;  void main() {     gl_Position = T_MVP * vec4(position.xy, 0.0, 1.0);     texCoord0 = texCoord;     worldPos0 = (T_model * vec4(position.xy, 0.0, 1.0)).xyz; }   #elif defined(FS_BUILD)  uniform sampler2D H_text; uniform vec3 H_textColor;  DeclareFragOutput(0, vec4); void main() {         vec4 sampled = vec4(1.0, 1.0, 1.0, texture2D(H_text, texCoord0).r);     vec4 color = vec4(H_textColor, 1.0) * sampled;     SetFragOutput(0, sampled * color); }   #endif 

Following this set-up of the textRenderObject game object, its Text game component and the text.glsl shader, every frame the following render function is called:

void TextRenderer::RenderTextRenderer(...) {     this->TextShader.Bind();//"text.glsl" created earlier     this->TextShader.UpdateUniformsTextRenderer(...);     RenderText("TEST test", 100, 100, 1);//responsible for drawing  } 

UpdateUniformsTextRenderer(...) is responsible for setting the values of the uniforms in text.glsl and is as follows:

void Shader::UpdateUniformsTextRenderer(Transform* transform, const RenderingEngine& renderingEngine, const Camera& camera) {     Matrix4f worldMatrix = transform->GetTransformation();     Matrix4f projectedMatrix = camera.GetViewProjection() * worldMatrix;     for (unsigned int i = 0; i < m_shaderData->GetUniformNames().size(); i++)     {         std::string uniformName = m_shaderData->GetUniformNames()[i];         std::string uniformType = m_shaderData->GetUniformTypes()[i];           if (uniformName.substr(0, 2) == "T_")         {             if (uniformName == "T_MVP")                 SetUniformMatrix4f(uniformName, projectedMatrix);             else if (uniformName == "T_model")                 SetUniformMatrix4f(uniformName, worldMatrix);             else                 throw "Invalid Transform Uniform: " + uniformName;         }         else if (uniformName.substr(0, 2) == "H_") {             if (uniformName == "H_text") {//Texture used to draw text                 int samplerSlot = renderingEngine.GetSamplerSlot(uniformName);                 SetUniformi(uniformName, samplerSlot);             }             else if (uniformName == "H_textColor")                 SetUniformVector3f(uniformName, Vector3f(1, 0, 0));//red         }     } } 

And finally the function RenderText that actually draws the text is as follows:

void TextRenderer::RenderText(std::string text, GLfloat x, GLfloat y, GLfloat scale) {     glActiveTexture(GL_TEXTURE0);     glBindVertexArray(this->VAO);      // Iterate through all characters     std::string::const_iterator c;     for (c = text.begin(); c != text.end(); c++)     {         Character ch = Characters[*c];          GLfloat xpos = x + ch.Bearing.x * scale;         GLfloat ypos = y + (this->Characters['H'].Bearing.y - ch.Bearing.y) * scale;          GLfloat w = ch.Size.x * scale;         GLfloat h = ch.Size.y * scale;         // Update VBO for each character         GLfloat vertices[6][4] = {             { xpos,     ypos + h,   0.0, 1.0 },             { xpos + w, ypos,       1.0, 0.0 },             { xpos,     ypos,       0.0, 0.0 },              { xpos,     ypos + h,   0.0, 1.0 },             { xpos + w, ypos + h,   1.0, 1.0 },             { xpos + w, ypos,       1.0, 0.0 }         };         // Render glyph texture over quad         glBindTexture(GL_TEXTURE_2D, ch.TextureID);         // Update content of VBO memory         glBindBuffer(GL_ARRAY_BUFFER, this->VBO);         glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); // Be sure to use glBufferSubData and not glBufferData          glBindBuffer(GL_ARRAY_BUFFER, 0);         // Render quad         glDrawArrays(GL_TRIANGLES, 0, 6);         // Now advance cursors for next glyph         x += (ch.Advance >> 6) * scale; // Bitshift by 6 to get value in pixels (1/64th times 2^6 = 64)     }     glBindVertexArray(0);     glBindTexture(GL_TEXTURE_2D, 0); } 

And that’s my implementation, can anyone see where I have gone wrong? Any feedback is much appreciated.

Finding longest word without help of library functions or regex?

Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty.

**Examples**

Taken from here https://coderbyte.com/information/Longest%20Word

Every single solution that came across in Javascript or C# are the ones which use regex. Is it possible to solve this without regex?

I gave it a shot but could not make it work:

function LongestWord(sen) {   let word = [];   let longestword = "";   let longestwordlen = 0;   let wordlen = 0;   for (let i = 0; i < sen.length - 1; i++) {      if (isAlphabet(sen[i]) && !isInvalidChar(sen[i + 1])) {       wordlen++;       word.push(sen[i]);     }     if (isSpace(sen[i + 1])) {       if (wordlen > longestwordlen) {         longestwordlen = wordlen;         longestword = word.join('')       }       wordlen = 0;       word = [];     }    }    return longestword; }  function isSpace(char) {   if (char.charCodeAt(0) == 32) return true   else return false } function isInvalidChar(char) {   if (!isSpace(char) && !isAlphabet(char)) return true   else return false } function isAlphabet(char) {   if ((char.charCodeAt(0) >= 65 && char.charCodeAt(0) <= 90) || (char.charCodeAt(0) >= 97 && char.charCodeAt(0) <= 122)) return true   else return false }  LongestWord("I am going to kill youeeeeee ")