Skip to content

Instantly share code, notes, and snippets.

View codepunkt's full-sized avatar

Christoph Werner codepunkt

View GitHub Profile
@sl4m
sl4m / gist:5091803
Created March 5, 2013 16:57 — forked from trcarden/gist:3295935
create self-signed certificate for localhost
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@OrganicPanda
OrganicPanda / hacky-scrollbar-resize-listener.js
Last active April 7, 2024 10:53
A sham that will throw a window resize event even when scrollbars are added/removed (this is not something the standard window resize event does). Tested in IE9+, Chrome & Firefox latest.
// Demo: http://jsfiddle.net/pFaSx/
// Create an invisible iframe
var iframe = document.createElement('iframe');
iframe.id = "hacky-scrollbar-resize-listener";
iframe.style.cssText = 'height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;';
// Register our event when the iframe loads
iframe.onload = function() {
// The trick here is that because this iframe has 100% width
@briancavalier
briancavalier / withSourceMaps.js
Last active January 5, 2016 07:40
Helper for simple support for source maps in when.js unhandled rejection reporting
var when = require('when');
unhandledRejectionsWithSourceMaps(when.Promise);
function unhandledRejectionsWithSourceMaps(Promise) {
Promise.onPotentiallyUnhandledRejection = function(r) {
setTimeout(function() {
if(!r.handled) {
throw r.value;
}
@derickfay
derickfay / fix_notes.applescript
Created April 16, 2015 16:55
Change Keynote Presenter Notes Font and Size for All Slides
tell application "Keynote"
tell document 1
set theSlides to slides
repeat with s in the slides
tell presenter notes of s
set font to "Helvetica"
set size to 24
end tell
end repeat
end tell
@brycebaril
brycebaril / output.md
Last active February 23, 2020 22:35
process.nextTick vs setImmediate

@mafintosh asks: "Does anyone have a good code example of when to use setImmediate instead of nextTick?"

https://twitter.com/mafintosh/status/624590818125352960

The answer is "generally anywhere outside of core".

process.nextTick is barely asynchronous. Flow-wise it is asynchronous, but it will trigger before any other asynchronous events can (timers, io, etc.) and thus can starve the event loop.

In this script I show a starved event loop where I just synchronously block, use nextTick and setImmediate

@gaearon
gaearon / ReduxMicroBoilerplate.js
Last active March 26, 2020 00:35
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
@molily
molily / bem.sass
Last active August 29, 2015 14:26
BEM helper mixins for Sass
// Mixins for generating Block Element Modifier (BEM) class names.
// See https://css-tricks.com/snippets/sass/bem-mixins/
// They can be nested to produce meaningful classes.
// To create a descendant selector like `.block--modifier .block__element`
// the block needs to be repeated. For example:
// +block(some-block)
//
// +element(some-element)
// color: red
//
'use strict'; // avoid ambiguity and sloppy errors
/**
* Tests wether or not a given string is a Palindrome
* @param {string} stringToTest - the string to test.
* @returns {boolean}
*/
function isPalindrome(stringToTest) {
var start = 0;
@daleobrien
daleobrien / install_git.sh
Created June 14, 2016 23:14
install git 2.9 on OSX
cd ~/Downloads
wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
tar -xvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
./Configure darwin64-x86_64-cc
make depend -j4
sudo make install
cd ~/Downloads
@icebob
icebob / merge.js
Created July 29, 2016 08:19
Merge GraphQL schemas & resolvers in modules
let moduleQueries = [];
let moduleTypeDefinitions = [];
let moduleMutations = [];
let moduleResolvers = [];
let files = config.getGlobbedFiles(path.join(__dirname, "**", "*schema.js"));
// Load schema files
files.forEach((file) => {
let moduleSchema = require(path.resolve(file));