Skip to content

Instantly share code, notes, and snippets.

@ysimonson
ysimonson / gist:7120798
Last active February 18, 2016 20:24
Tornado decorator to make an endpoint prerenderable for search engine crawlers
# This has been turned into a full-fledged repo:
# https://github.com/dailymuse/torender
@rom3r4
rom3r4 / gist:ba0c1001b696d5faaa5f1f1a29436ef3
Created April 14, 2016 00:47 — forked from guilherme/gist:9604324
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit.
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='console.log'
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@dgorissen
dgorissen / jquery.bootstrap.confirm.popover.js
Created November 3, 2011 13:15
Confirmation dialog using jQuery and Bootstrap
/*
Copyright (c) 2011 Damien Antipa, http://www.nethead.at/, http://damien.antipa.at
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@GerHobbelt
GerHobbelt / .gitignore
Created September 9, 2012 08:04
d3.js: using tree layout for graphs which have nodes with multiple 'parents'
# Editor backup files
*.bak
*~
@engintekin
engintekin / Application.java
Created October 26, 2011 20:02
Gzip your response in Play framework
@With(Compress.class)
public class Application extends Controller {
public static void index() {
render();//response will be gzipped
}
}
@aseemk
aseemk / i18n._coffee
Last active January 28, 2019 14:52
Node.js script to extract i18n strings from source code.
#!/usr/bin/env _coffee
#
# Helper script to search all of our files for i18n strings and update our
# strings file. Helpful in case we missed a code path during testing.
#
# Specifically, searches for gettext `__()` calls in our checked-in files.
#
$ = require 'underscore'
echo = console.log
@ches
ches / gist:243611
Created November 26, 2009 19:09 — forked from lukesutton/gist:107966
basic example of Warden authentication with Sinatra
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end
@hieubuiduc
hieubuiduc / nginx_install.sh
Last active March 17, 2020 13:01
Script to install/upgrade Nginx (Naxsi, PageSpeed, PCRE) from sources on CentOS 6
#!/bin/bash
#
# Script to install/upgrade Nginx(Naxsi,PageSpeed,PCRE) from sources on CentOS 6
#
# Author: Duc Hieu - 12/2014.
# Base System: CentOS release 6.6 (Final)
# License: MIT
#
# Syntax: # sh nginx_install.sh
#
@sauloperez
sauloperez / signal_catching.rb
Last active November 11, 2020 11:25
How to catch SIGINT and SIGTERM signals in Ruby
# Signal catching
def shut_down
puts "\nShutting down gracefully..."
sleep 1
end
puts "I have PID #{Process.pid}"
# Trap ^C
Signal.trap("INT") {
@aldo-roman
aldo-roman / compress.js
Last active November 11, 2021 13:48
Brotli compression with Angular CLI
const brotli = require('brotli')
const fs = require('fs')
const brotliSettings = {
extension: 'br',
skipLarger: true,
mode: 1, // 0 = generic, 1 = text, 2 = font (WOFF2)
quality: 10, // 0 - 11,
lgwin: 12 // default
}