Skip to content

Instantly share code, notes, and snippets.

View tleunen's full-sized avatar
💭
I may be slow to respond.

Tommy tleunen

💭
I may be slow to respond.
View GitHub Profile
@tleunen
tleunen / google_closure_compiler_args.txt
Created August 27, 2014 12:36
Help for the arguments available for Google Closure Compiler
--accept_const_keyword : Allows usage of const keyword.
--angular_pass : Generate $inject properties for
AngularJS for functions annotated
with @ngInject
--charset VAL : Input and output charset for all
files. By default, we accept UTF-8 as
input and output US_ASCII
--closure_entry_point VAL : Entry points to the program. Must be
goog.provide'd symbols. Any goog.provi
de'd symbols that are not a transitive
@tleunen
tleunen / static_webserver_nodejs.js
Last active December 12, 2015 02:58
Simple static files webserver in NodeJS (with SSL in comments)
var http = require('http'),
https = require('https'),
fs = require('fs'),
url = require('url');
/*
var options = {
key: fs.readFileSync('ssl/server.key'),
cert: fs.readFileSync('ssl/server.crt')
};
*/
@tleunen
tleunen / ahref-expandable-button.css
Last active December 17, 2015 04:18
Create an expandable ahref button in width, with 3 background image in css (left, middle and right parts). All this keeping the html very simple.
.cbtn {
position: relative;
top: 0px;
left: 9px; /* same as width of left part (:before) */
background: url(img/middle.png);
height: 50px; /* height of the background image */
color: #000;
@tleunen
tleunen / bit-reverse.js
Created February 3, 2013 17:55
Function to reverse the bits of a given integer
function bitRev(N) {
var r = 0;
val = 0;
while(N > 0) {
val = N&1;
N >>= 1;
r += val&1;
r <<= 1;
@tleunen
tleunen / create-reducer.js
Last active March 16, 2018 15:20
Easy create a redux reducer
export default function createReducer(initialState, handlers) {
return function reducer(state = initialState, action) {
let nextState = state;
if ({}.hasOwnProperty.call(handlers, '*')) {
nextState = handlers['*'](nextState, action);
}
if ({}.hasOwnProperty.call(handlers, action.type)) {
return handlers[action.type](nextState, action);
@tleunen
tleunen / expandable-button.css
Created May 15, 2013 01:56
Create an expandable button in width, with 3 background image in css (left, middle and right parts). All this keeping the html very simple.
.cbtn {
position: relative;
top: 0px;
left: 9px; /* width of left part (:before) */
overflow: visible; /* this make the :before and :after in position:absolute to appear */
background: url(img/middle.png);
height: 50px;
padding: 0;
@tleunen
tleunen / webtask-openexchangerate.js
Last active May 30, 2018 02:52
webtask-openexchangerate
const request = require('request');
const OPEN_EXCHANGE_API_URL = 'https://openexchangerates.org/api';
const OE_LATEST = `${OPEN_EXCHANGE_API_URL}/latest.json`;
module.exports = function(ctx, done) {
const APP_ID = ctx.data.APP_ID;
const url = `${OE_LATEST}?app_id=${APP_ID}`;
@tleunen
tleunen / embed-gist-angularjs.html
Last active May 1, 2019 00:51
Here is a directive in AngularJS to embed a Gist. This technique uses an iframe to add the gist because AngularJS doesn't handle script tags inside a template. And even if it does (with jQuery), it won't work as expected because Gist uses document.write. The iframe solves both issues.
<!-- In your template -->
<div data-gist="{{gistId}}"></div>