Skip to content

Instantly share code, notes, and snippets.

@xfsnowind
xfsnowind / git-status-after-mixed-reset.sh
Created September 29, 2015 18:43
show git status after git mixed reset on blog difference among soft mixed and hard of git command git reset on 2014/03/26
# Shell
> git reset --mixed HEAD~1
> git status
On branch master Untracked files:
(use "git add <file>..." to include in what will be committed)
mappe/
stagingMappe/
> tree
├── mappe
│ └── mappeFil
@xfsnowind
xfsnowind / git-status-after-hard-reset.sh
Created September 29, 2015 18:45
how git status after git hard reset on blog difference among soft mixed and hard of git command git reset on 2014/03/26
# Shell
> git reset --hard HEAD~1
> git status
On branch master Untracked files:
(use "git add <file>..." to include in what will be committed)
stagingMappe/
nothing added to commit but untracked files present
(use "git add" to track)
> tree
├── stagingMappe
@xfsnowind
xfsnowind / nodes.html
Created September 29, 2015 19:06
html nodes on blog "Handle Jquery object with Lazy.js" on 2014/04/07
<div class="castle"></div>
<div class="castle"></div>
<div class="castle"></div>
<div class="castle"></div>
@xfsnowind
xfsnowind / castle-lazy.js
Created September 29, 2015 19:07
lazy operations to html nodes on blog "Handle Jquery object with Lazy.js" on 2014/04/07
lazy($(".castle")).map(mapFunc)
.reduce(reduceFunc)
.each(eachFunc);
@xfsnowind
xfsnowind / js-console.sh
Created September 29, 2015 19:08
javascript console result of object on blog "Handle Jquery object with Lazy.js" on 2014/04/07
// Javascript console
ObjectWrapper {source: jQuery.fn.init[4], root: function, get: function, each: function, watch: function…}
├──source: jQuery.fn.init[4]
│ ├──0: div.castle
│ ├──1: div.castle
│ ├──2: div.castle
│ ├──3: div.castle
├──context: document
├──length: 4
├──prevObject: jQuery.fn.init[1]
@xfsnowind
xfsnowind / castle-lazy-length.js
Created September 29, 2015 19:09
length of lazy operations to html nodes on blog "Handle Jquery object with Lazy.js" on 2014/04/07
//show the length of $(".castle")
> lazy($(".castle")).size()
154
//show the length of functions in $(".castle")
> lazy($(".castle")).functions().size()
145
@xfsnowind
xfsnowind / castle-lazy-array.js
Created September 29, 2015 19:10
lazy operations to html node array on blog "Handle Jquery object with Lazy.js" on 2014/04/07
lazy($(".castle").toArray()).map(mapFunc)
.reduce(reduceFunc)
.each(eachFunc);
@xfsnowind
xfsnowind / debounce.clj
Created October 23, 2015 22:08
The clojure version with library core.async of debounce function
(defn debounce-chan
"Taken from https://github.com/swannodette/async-tests
A little different with original one, write to channel after the interval
instead of doing it in the beginning"
([source msecs]
(debounce-chan (chan) source msecs))
([c source msecs]
(go-loop [state ::init
last-one nil
cs [source]]
@xfsnowind
xfsnowind / debounce-resize.js
Created October 23, 2015 22:25
apply debounce to resize event on blog "Introducing Javascript method debounce" on 2014/05/12
var timeout;
$(window).resize(function () {
function delayed () {
//the operation needed
timeout = null;
}
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(delayed, 500);
@xfsnowind
xfsnowind / debounce-resize--with-immediate.js
Created October 23, 2015 22:28
apply debounce with parameter immediate to resize event on blog "Introducing Javascript method debounce" on 2014/05/12
var timeout;
var immediate = true;
var wait = 500;
$(window).resize(function () {
console.log("debounced");
function delayed () {
if (!immediate) {
//the operation needed
}
timeout = null;