Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Maximilian Hoffmann maxhoffmann

👋
View GitHub Profile
View express-static.js
function onlyStatic (middleware) {
return function (req, res, next) {
var match = /(\.css|\.eot|\.gif|\.html|\.js|\.png|\.svg|\.ttf|\.woff|\.jpg)($|\?.*$)/ig.exec(req.originalUrl);
if (!match) return next();
middleware(req, res, next);
};
}
//usage
this.use(onlyStatic(express.static(__dirname + "/public")));
@paulmillr
paulmillr / safari-web-inspector.md
Last active Oct 12, 2015
Safari web inspector evolution
View safari-web-inspector.md

As a developer, i’m curious what happens to tools I use. Some time ago I decided to log all changes in web inspectors of browsers.

So far list includes only Safari and Firefox primarly because it’s easy to track their changes. In the future other browsers will be in too.

Safari web inspector evolution

  • August 2012: Initial release of new safari web inspector. It had terrible UI / UX.
  • October:
    • Reduced main panels count from 8 to 3-4.
  • November:
@cowboy
cowboy / Abstraction.js
Created May 24, 2012
A modern JavaScript if-elseif-else abstraction, because control flow statements are so 1995
View Abstraction.js
/*
* Abstraction.js
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
var Abstraction = (function($) {
var _ = $.prototype;
@szabba
szabba / .gitignore
Last active Jun 1, 2016 — forked from maxhoffmann/Main.elm
Token HTTP Authentication in Elm
@spoike
spoike / reactjs_componentapi_cheatsheet.md
Created May 13, 2014
React JS Cheatsheets for Component API, Specifications and Lifecycle
View reactjs_componentapi_cheatsheet.md

ReactJS Component Cheatsheet

To create a ReactComponent:

ReactComponent React.createClass(object proto)

Basic JSX example:

var TitleComponent = React.createClass({
  // REQUIRED
View notification.js
var $ = require('NodObjC');
$.import('Cocoa');
var installNSBundleHook = function() {
var cls = $.NSBundle;
if (cls) {
var bundleIdentifier = cls.getInstanceMethod('bundleIdentifier');
bundleIdentifier.setImplementation(function(val) {
@jackfuchs
jackfuchs / jquery.support.cssproperty.js
Last active Aug 26, 2019
Extends the jQuery.support object to CSS Properties
View jquery.support.cssproperty.js
/**
* jQuery.support.cssProperty
* To verify that a CSS property is supported
* (or any of its browser-specific implementations)
*
* @param p css property name
* @param rp optional, if set to true, the css property name will be returned
* instead of a boolean support indicator
* @return {mixed}
*
@yelouafi
yelouafi / FP_Observables.js
Last active Mar 1, 2021
Observables with pure FP
View FP_Observables.js
// Observable is an Union Type, with the following variants
const Empty = () => ['EMPTY']
const Cons = (head, tail) => ['CONS', head, tail]
const Future = promise => ['FUTURE', promise]
// race between 2 promises; each promise will resolve to a lazy value
const lazyRace = (p1, p2) => Promise.race([p1,p2]).then(lazy => lazy())
// function composition
const compose = (...fns) => (arg) => fns.reduceRight((res, f) => f(res), arg)
View bloop.js
(function() {
// Do not use this library. This is just a fun example to prove a
// point.
var Bloop = window.Bloop = {};
var mountId = 0;
function newMountId() {
return mountId++;
}
@ingramchen
ingramchen / gist:e2af352bf8b40bb88890fba4f47eccd0
Created Apr 5, 2016
ffmpeg convert gif to mp4, for best cross browser compatibility
View gist:e2af352bf8b40bb88890fba4f47eccd0
### Full command line options
```
ffmpeg -f gif -i FOO.gif -pix_fmt yuv420p -c:v libx264 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' BAR.mp4
```
### Notie
* output mp4 is encoded with h264, support Firefox/Chrome/Safari in Windows, Mac OSX, Android, and iOS.