Skip to content

Instantly share code, notes, and snippets.

@weisk
weisk / multiple_ssh_setting.md
Last active August 27, 2015 18:00 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@weisk
weisk / smoothscrolling.coffee
Created May 5, 2015 15:06
Smooth Scrolling
app.run ($rootScope, $state, SessionService, $window) ->
$rootScope.$state = $state
$rootScope.logout = -> SessionService.logout true
win = $($window)
scrollTime = 0.3
scrollDistance = 200
win.on 'mousewheel DOMMouseScroll', (evt) ->
evt.preventDefault()
@weisk
weisk / parallax.coffee
Last active August 29, 2015 14:20
Angular Parallax image & background
angular.module 'directives'
### Usage:
<div
parallax-background
parallax-background-ratio="0.6"
parallax-background-src="assets/image.png"
parallax-background-gradient="linear-gradient(rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.4) 100%)">
</div>
###
@weisk
weisk / connecthistoryapi.coffee
Created November 7, 2015 11:23
gulp task connect history api enhanced
gulp.task 'connect', [], -> connect.server
root: ['build']
port: 9000
livereload: true
middleware: (connect, opt) -> [
historyApiFallback = (req, res, next) ->
headers = req.headers
rewriteTarget = '/index.html'
appBaseDir = 'build'
@weisk
weisk / introrx.md
Created December 25, 2015 21:15 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@weisk
weisk / levenshtein.js
Created July 2, 2016 15:08 — forked from andrei-m/levenshtein.js
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/*
Copyright (c) 2011 Andrei Mackenzie
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@weisk
weisk / lodash-data-transformation.md
Created August 6, 2016 09:02
Lodash snippets - data transformation

Sort object by values

let doo = {Derp: 17, Herp: 2, Asd: 5, Foo: 8, Qwe: 12};

let foo = _.chain(doo)
  .map((val, key) => {
    return { name: key, count: val }
  })
  .sortBy('count')
 .reverse()
@weisk
weisk / promise_deferred.js
Created August 8, 2016 17:04
Promise ES6 deferred helper
function Deferred() {
var resolve, reject;
var promise = new Promise((resolver, rejector) => {
resolve = resolver;
reject = rejector;
});
return {
promise,
resolve,
reject
@weisk
weisk / 13-async.js
Created August 12, 2016 17:57
learnyounode 13 async
var http = require('http');
var requests = process.argv.slice(2);
var results = [];
var count = 0;
for (var i = 0, len = requests.length; i < len; i++) {
getRequest(requests[i], i);
}
@weisk
weisk / gist:4baead030f7dd4e690d56a3b884803c6
Created August 26, 2016 07:18 — forked from callmephilip/gist:3517765
[JavaScript] Dispatching mouse move event
// look here for more details : https://developer.mozilla.org/en-US/docs/DOM/event.initMouseEvent
var mouseMoveEvent = document.createEvent("MouseEvents");
mouseMoveEvent.initMouseEvent(
"mousemove", //event type : click, mousedown, mouseup, mouseover, mousemove, mouseout.
true, //canBubble
false, //cancelable
window, //event's AbstractView : should be window
1, // detail : Event's mouse click count