Skip to content

Instantly share code, notes, and snippets.

View drexler's full-sized avatar
💭
flipping bits...

andrew quartey drexler

💭
flipping bits...
View GitHub Profile
@csandman
csandman / react-scripts-env-priorities.md
Last active December 15, 2023 00:17
The priorities of different .env files used in different React scripts

What other .env files can be used?

Note: this feature is available with react-scripts@1.0.0 and higher.

  • .env: Default.
  • .env.local: Local overrides. This file is loaded for all environments except test.
  • .env.development, .env.test, .env.production: Environment-specific settings.
  • .env.development.local, .env.test.local, .env.production.local: Local overrides of environment-specific settings.

Files on the left have more priority than files on the right:

@nzvtrk
nzvtrk / axiosInterceptor.js
Last active December 7, 2023 17:21
Axios create/recreate cookie session in node.js enviroment
/* Basic example of saving cookie using axios in node.js and session's recreation after expiration.
* We have to getting/saving cookie manually because WithCredential axios param use XHR and doesn't work in node.js
* Also, this example supports parallel request and send only one create session request.
* */
const BASE_URL = "https://google.com";
// Init instance of axios which works with BASE_URL
const axiosInstance = axios.create({ baseURL: BASE_URL });
@hanxue
hanxue / embed-gist-in-blogger.js
Created January 18, 2014 10:48
Embed Gists in Blogger
At the end of your Blogger post , using HTML editor, append this
<script src="https://raw.github.com/moski/gist-Blogger/master/public/gistLoader.js" type="text/javascript"></script>
In the content of your blog post, simply add this:
<div class="gistLoad" data-id="8488564" id="gist-8488564">Loading https://gist.github.com/8488564....</div>
Note: adding the URL is useful because when the javascript does not work, readers can copy and paste the URL themselves.
@leoapost
leoapost / gist:4318441
Created December 17, 2012 13:55
Delete all remote branches, except master
# Replace REMOTE_NAME with your remote name (e.g. origin)
git branch -r | grep REMOTE_NAME/ | grep -v 'master$' | grep -v HEAD| cut -d/ -f2 | while read line; do git push REMOTE_NAME :$line; done;
@pgolding
pgolding / policy.md
Last active October 18, 2022 13:21
s3 bucket policy for presigned URLs generated by serverless lambda functions

AWS Presigned URLs

Presigned URLs are useful for fine-grained access control to resources on s3.

For example, if storing larger text blocks than DynamoDB might allow with its 400KB size limits s3 is a useful option.

Ignoring various ACL methods and using presigned URLs, it's possible to create lambda functions that can generate the required upload and download URLs.

Using the default IAM roles and lambda proxy configuration of serverless, lambdas are assigned an IAM role for the application (so that a logical group of functions can share resources - e.g. for a CRUD REST API). Each function then assumes the IAM role via its own function name.

@mlconnor
mlconnor / elastic_beanstalk_external_sessions.md
Created October 17, 2014 20:26
Analaysis and recommendation for externalizing session in Elastic Beanstalk using Tomcat and memcached.

Session Management in an Autoscaling Environment

Problem Statement

User sessions in J2EE and LAMP stacks have traditionally been handled in memory by the application server handling the user request. Because of that, load balancers have been configured to use sticky sessions. By sticky sessions we mean that once the user has visited the site, they will be assigned an app server and will return to that server for subsequent requests. The load balancers typically handle that by referencing the users session cookie.

Elastic cloud environments differ from traditional server configurations in that they have a variable number of servers based on traffic loads whereas traditional configurations had a fixed number of servers. When traffic volumes decline it is necessary to vaporize servers. In doing so, we would lose user sessions (essentially forcing a logout) unless we come up with a new strategy for session management.

A new approach

After much research, it is clear that the best

@tinovyatkin
tinovyatkin / promisify-readline-question.js
Created October 29, 2017 15:58
`util.promisify` for `readline.question`
'use strict';
// Promisifies readline.question function using node native `util.promisify`
// readline.question takes one callback that returns the answer, so it need custom promisifying
const readline = require('readline');
const { promisify } = require('util');
readline.Interface.prototype.question[promisify.custom] = function(prompt) {
return new Promise(resolve =>
@keyle
keyle / HDD.groovy
Created August 4, 2014 10:34
Groovy. Write objects to file (json) and read them back
package utils
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
class HDD {
static save(Object content, String filePath) {
new File(filePath).write(new JsonBuilder(content).toPrettyString())
}
@paulomcnally
paulomcnally / hash.c
Last active September 23, 2019 22:18
Generating PBKDF2 keys in C# and NodeJS
public string hash(string pwd,string salt) {
Rfc2898DeriveBytes pdb;
Byte[] byteValue = System.Text.Encoding.UTF8.GetBytes(salt);
pdb = new Rfc2898DeriveBytes(pwd, byteValue, 1333);
return Convert.ToBase64String(pdb.GetBytes(32));
}
@alexellis
alexellis / README.md
Last active May 23, 2019 07:24
OpenFaaS Cloud Community Cluster instructions