Skip to content

Instantly share code, notes, and snippets.

View premasagar's full-sized avatar

Prem Rose premasagar

View GitHub Profile
@larister
larister / Preferences.sublime-settings
Created October 28, 2012 15:27
Sublime Text 2 preferences
{
// Show folders in the side bar in bold
"bold_folder_labels": true,
// Word list to use for spell checking
"dictionary": "Packages/Language - English/en_GB.dic",
// Set to true to draw a border around the visible rectangle on the minimap.
// The color of the border will be determined by the "minimapBorder" key in
// the color scheme
@mahemoff
mahemoff / staptrap.coffee
Created November 6, 2012 04:18
Mousetrap.js support for Bootstrap with help dialog
# Monkey-patch stopCallback so that Mousetrap will ignore any keyboard action during modal
((originalStopCallback) -> Mousetrap.stopCallback = ->
return true if $('body.modal-open').length
originalStopCallback.apply(Mousetrap, arguments)
)(Mousetrap.stopCallback)
# "?" key will produce keyboard shortcuts dialog (as on Twitter and GitHub)
# It fetches the dialog content on demand for performance reasons
Mousetrap.bind '?', ->
$.get '/docs/keyboard_shortcuts', (html) ->
@wrr
wrr / index.html
Last active May 14, 2019 00:27
Random walk illustrated with D3.
<!DOCTYPE html>
<!-- By Jan Wrobel. See it working at:
http://mixedbit.org/blog/2013/02/10/random_walk_illustrated_with_d3.html
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Random walk</title>
@bkeepers
bkeepers / .gitconfig
Created February 19, 2013 14:12
Git aliases to make new commits that fixup or are squashed into previous commits
[alias]
fixup = !sh -c 'REV=$(git rev-parse $1) && git commit --fixup $@ && git rebase -i --autosquash $REV^' -
squash = !sh -c 'REV=$(git rev-parse $1) && git commit --squash $@ && git rebase -i --autosquash $REV^' -
@bgrins
bgrins / Log-.md
Last active July 11, 2024 13:40
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@plentz
plentz / nginx.conf
Last active May 21, 2025 05:22
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@jonbretman
jonbretman / type.js
Last active January 16, 2024 01:16
Simple type checking in JavaScript.
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements
@staltz
staltz / introrx.md
Last active May 21, 2025 19:32
The introduction to Reactive Programming you've been missing
@WebReflection
WebReflection / String.prototype.template.js
Last active August 17, 2022 04:04
ES6 Template like strings in ES3 compatible syntax.
// this is now a module:
// https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines--
var template = require('backtick-template');
// just string
const info = 'template';
`some ${info}` === template('some ${info}', {info});