Skip to content

Instantly share code, notes, and snippets.

@denwwer
denwwer / gist:a572e1f14dd21661217e248b2e827062
Created October 3, 2018 13:46 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@denwwer
denwwer / letsencrypt_2017.md
Created January 4, 2018 13:54 — forked from sdrew/letsencrypt_2017.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@denwwer
denwwer / facebook-node-sdk-sample.js
Created November 21, 2017 10:44 — forked from dai-shi/facebook-node-sdk-sample.js
A sample code to get an application access token using Thuzi / facebook-node-sdk.
var FB = require('fb');
FB.api('oauth/access_token', {
client_id: process.env.FACEBOOK_APP_ID,
client_secret: process.env.FACEBOOK_SECRET,
grant_type: 'client_credentials'
}, function(res) {
if (!res || res.error) {
console.log('error occurred when getting access token:', res && res.error);
return;
@denwwer
denwwer / main.go
Created November 15, 2017 10:55 — forked from divan/main.go
Golang database/sql+http example (postgres)
// Run PostgreSQL server:
// docker run -e POSTGRES_PASSWORD="" -p 5432:5432 postgres
// Monitor running processes:
// watch -n 1 'echo "select pid,query_start,state,query from pg_stat_activity;" | psql -h localhost -U postgres
//
// For all handlers, call to db takes 5 seconds,
//
// Three endpoints:
// - "/" - take 5 seconds
// - "/ctx" - take 1 seconds, due to 1 second cancellation policy
@denwwer
denwwer / checkbox.js
Last active March 24, 2017 11:11
Handle unchecked checkboxes
$('input[type="checkbox"]').bind('change', function() {
var $checkbox = $(this);
var id = this.id + '-hidden';
if ($checkbox.is(':checked')) {
$('#' + id).detach();
} else {
var name = $checkbox.attr('name');
$checkbox.before('<input type="hidden" name="'+ name +'" value="0" id="'+ id +'">');
}
@denwwer
denwwer / gist:b3cacaa6472981a332880d51ce3f9764
Created February 27, 2017 16:41 — forked from tomess/gist:4692191
CSS: rem/px font-size-Tabelle
font-size:10px;
font-size:0.625rem;
font-size:11px;
font-size:0.6875rem;
font-size:12px;
font-size:0.75rem;
font-size:13px;
@denwwer
denwwer / nginx.conf
Last active January 5, 2017 17:09
nginx conf to redirect form http/www to https on AWS ELB
# set DOMAIN_NAME to your domain, example "google.com"
# server {
set $https_redirect 0;
if ($http_host = 'www.DOMAIN_NAME') {
set $https_redirect 1;
}
@denwwer
denwwer / ember-cucumber.rb
Created December 15, 2016 10:15 — forked from trianglegrrl/ember-cucumber.rb
Testing Ember with Cucumber
# You need some sort of indication that an Ajax transaction exists. jQuery.active doesn't seem to do the
# trick, so we use the following JS (well, we use CoffeeScript, but whatever) that gets inserted into
# our application.
#
#$(function() {
# var body, doc;
# body = $('body');
# doc = $(document);
# doc.ajaxStart(function() {
# return body.addClass('ajax-in-progress').removeClass('ajax-quiet');
# This class shows uses version 0.9.x of the ruby google-api-client gem circa July 2016
# to query the Google Play subscription API.
#
# If using an older version of the google-api-client gem (ie. version 0.8.x), instead refer to:
# https://gist.github.com/jkotchoff/e60fdf048ec443272045/e3e2c867633900d9d6f53de2de13aa0a0a16bb03
#
# Sample usage:
#
# package_name = 'com.stocklight.stocklightapp'
# product_id = 'com.stocklight.stocklight.standardsubscription'
@denwwer
denwwer / 00.howto_install_phantomjs.md
Created September 20, 2016 20:37 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev