Skip to content

Instantly share code, notes, and snippets.

@rudylattae
rudylattae / Jaxy.js
Created August 6, 2011 08:09
Zyx.js -- a collection of microjs helpers
var Jaxy = function() {
this.xhr = new XMLHttpRequest;
};
Jaxy.prototype.get = function(options) {
if (typeof options.url === 'undefined') return;
var self = this;
var url = options.url || '';
var success = options.success || null;
var error = options.error || null;
@jimjeffers
jimjeffers / html5VideoAspectRatioAdjustment.coffee
Created September 15, 2011 13:24
Breaking the HTML5 Video Aspect Ratio
# Just an example.
# @video is a direct reference to a '<video>' element.
# $() is assuming jQuery is being used in this example.
@video.addEventListener("loadedmetadata", (event) =>
actualRatio = @video.videoWidth/@video.videoHeight
targetRatio = $(@video).width()/$(@video).height()
adjustmentRatio = targetRatio/actualRatio
$(@video).css("-webkit-transform","scaleX(#{adjustmentRatio})")
)
@bradland
bradland / ssh-known-hosts-mgmt.sh
Last active April 4, 2023 21:21
SSH known_hosts tools
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -F github.com
@dhm116
dhm116 / ie.shims.js
Created February 10, 2012 15:14
IE7/8 Javascript method shims
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);
@brianwisti
brianwisti / default.coffee
Created June 11, 2012 14:46
Metro "Hello World" JavaScript, but in CoffeeScript
# Blank Metro Template, but in CoffeeScript
# Just a dumb rewrite of the default.js in
# http://msdn.microsoft.com/en-us/library/windows/apps/hh986964.aspx
buttonClickHandler = (eventInfo) ->
userName = document.getElementById("nameInput").value
greetingString = "Hello, #{userName}!"; # oh yeah, CS does string interpolation
document.getElementById("greetingOutput").innerText = greetingString
app = WinJS.Application
@awidegreen
awidegreen / vim_cheatsheet.md
Last active June 17, 2024 03:41
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@gsomoza
gsomoza / .bashrc
Created January 17, 2013 16:50
SSH Agent in Windows (Git Bash / MinGW)
#!bash.exe
export SSH_AUTH_SOCK=/tmp/.ssh-socket
echo ;
echo Starting connection with ssh-agent...
ssh-add -l 2>&1 >/dev/null
if [ $? = 2 ]; then
rm -f /tmp/.ssh-script /tmp/.ssh-agent-pid /tmp/.ssh-socket
# Exit status 2 means couldn't connect to ssh-agent; start one now
echo Creating new ssh-agent...
ssh-agent -a $SSH_AUTH_SOCK > /tmp/.ssh-script
@raimohanska
raimohanska / bacon-fold.js
Created January 31, 2013 21:13
Fold in Bacon.js
Bacon.Observable.prototype.fold = function(seed, f) {
var scanned = this.scan(seed, f)
return scanned.changes().mapEnd().map(scanned)
}
@johnnyelwailer
johnnyelwailer / keyboard_navigation_service.js
Last active July 6, 2016 10:47
keyboard navigation directive / service in angular js (depends on jq and rxjs)
angular.module('keyboard', [])
.factory('keyboardNavigation', function () {
var keyboardContextStack = [];
var navigatables = {};
var activeIndex = 0;
return {
active: null,
register: function (scope, events) {
@maccman
maccman / jquery.onclose.coffee
Last active July 3, 2022 08:17
jQuery plugin to notify users if they close the page, and there are still some Ajax requests pending.
$ = jQuery
TRANSFORM_TYPES = ['PUT', 'POST', 'DELETE']
$.activeTransforms = 0
$(document).ajaxSend (e, xhr, settings) ->
return unless settings.type in TRANSFORM_TYPES
$.activeTransforms += 1