Skip to content

Instantly share code, notes, and snippets.

View waghcwb's full-sized avatar
🎧
‌‌

Wagner Souza waghcwb

🎧
‌‌
View GitHub Profile
@ndelage
ndelage / Tips for a #WINNING Github Profile.md
Last active November 9, 2021 03:11
Tips for a #WINNING Github Profile

Tips for a #WINNING Github Profile

The basics

As a new developer some potential employers are going to review your Github profile as part of the interview process. This doc covers some tips that should help you make a good impression. What this doc won't do is polish a turd.

README

Think of your experiences reviewing a Gem or other JS library on Github. Where do you look first? The README of course. What makes for a frustrating repo? One that doesn't:

  • include a README.
  • include install instructions (if applicable)
@tmpvar
tmpvar / my-first-module.md
Last active December 20, 2021 18:48
how to create your very first node.js module and publish it to the npm registry

building your first node module

This is pretty simple, lets dive in!

choose a name

Find a name that isn't taken and clearly describes what your module is doing

$ npm view your-first-node-module
@josephspurrier
josephspurrier / md5.go
Created August 26, 2015 21:44
MD5 Hash Generator in Golang
package main
// Source: https://www.socketloop.com/tutorials/how-to-generate-checksum-for-file-in-go
import (
"crypto/md5"
"fmt"
"io"
"math"
"os"
@HarshithaKP
HarshithaKP / SessionPersistence.js
Last active February 12, 2022 09:19
Demonstration of how user session can be persisted across redirects, with an express server and request client.
var express = require('express')
var session = require('express-session')
var app = express()
var r = require('request')
// By default cookies are disabled, switch it on
var request = r.defaults( { jar:true } )
app.use(session({ secret: 'keyboard cat',saveUninitialized : false, resave : false, cookie: { maxAge: 60000 }}))
@rakslice
rakslice / gist:f9ef03bd31c03f2a868d6d080708007f
Created June 6, 2018 11:53
hide title bar in zserge/webview
$ git diff
diff --git a/webview.h b/webview.h
index 61f7146..5847ac8 100644
--- a/webview.h
+++ b/webview.h
@@ -1244,6 +1244,7 @@ WEBVIEW_API int webview_init(struct webview *w) {
return -1;
}
+ SetWindowLong(w->priv.hwnd, GWL_STYLE, WS_DLGFRAME);
@heygrady
heygrady / preloading-data-redux.md
Created March 1, 2018 02:06
Preloading data in a redux application

Preloading data in a redux application

A redux app is a chicken and egg problem. Given a particular state, the app should render a certain thing. But... where does that state come from?

Starting from empty

Given a blank state, the app needs to rely on the URL to fetch the right data to populate the state.

In a server-side app, the initial state is determined in exactly this way. Given the initial URL, populate the state, render the app, send it to the client.

In a client-side app the situation is exactly the same, except it's totally different. On the client you have way more contextual information than just the URL. Given the URL, the current app state, a components own props and its internal state... a component must decide which data it needs loaded.

@cjavad
cjavad / M11.js
Last active May 24, 2022 19:16
Module 11 integration in javascript/nodejs with 18 integers
// M11.js
/*
* Modules 11 control algorithm it's used
* Used by the danish goverment to validate CPR numbers (social security numbers).
* It works by having a number list and giving them each a weight from 2 to 7 then
* multiplying them to then divide the number with the mod (11 usually)
* to see if the reminder is 0.
*
* the modules operator (%) in javascript takes bad values.
@nickcarenza
nickcarenza / lazy_evaluation.go
Created February 20, 2015 18:35
Golang Lazy Evaluation
package main
import (
"time"
)
type LazyInt chan func() int
// Can't use pointer receiver: invalid operation: l <- (func literal) (send to non-chan type *LazyInt)
func (l LazyInt) Future(i int) {
@ziggi
ziggi / parents.js
Last active August 11, 2022 16:10
Vanilla JS jQuery.parents() realisation (npm module: https://github.com/ziggi/dom-parents)
Element.prototype.parents = function(selector) {
var elements = [];
var elem = this;
var ishaveselector = selector !== undefined;
while ((elem = elem.parentElement) !== null) {
if (elem.nodeType !== Node.ELEMENT_NODE) {
continue;
}
@simlevesque
simlevesque / gist:58ecb8477188f903fef72a5601f0a069
Created September 25, 2019 21:52
aws v4 signature in modern js (sigv4.js)
'use strict';
const crypto = require('crypto');
module.exports = function (accessKey, secretKey, requestHeaders, httpMethod, path, payload, region, service, timestamp) {
const signedHeaders = createSignedHeaders(requestHeaders);
const canonicalRequest = createCanonicalRequest(httpMethod, path, requestHeaders, payload);
const stringToSign = createStringToSign(timestamp, region, service, canonicalRequest);
const signature = createSignature(secretKey, timestamp, region, service, stringToSign);
const authorizationHeader = createAuthorizationHeaders(timestamp, accessKey, region, service, signedHeaders, signature);