Skip to content

Instantly share code, notes, and snippets.

View techsin's full-sized avatar
🏠
Working from home

techsin techsin

🏠
Working from home
  • New York, NY
View GitHub Profile
var that = this;
setTimeout(function(){
that.style.backgroundColor='red';
},1000);
@techsin
techsin / asyncjs
Created April 13, 2015 02:26
Testing asynchs functionality
function async1(cb,err) {
setTimeout(function () {
console.log(1);
cb();
}, 1000);
}
function async2(cb,err) {
setTimeout(function () {
cb(new Error());
@techsin
techsin / get
Last active August 29, 2015 14:21
get
(function(){function h(a,e){var b=a.data;b.children.forEach(function(a){d=a.data;c.push({title:d.title||d.link_title,url:(d.url||d.link_url)+(-1<d.name.indexOf("t1")&&d.id),name:d.name,subreddit:d.subreddit,context:"http://www.reddit.com/"+(d.link_id&&d.link_id.match(/t._([^&]*)/)[1]||d.id)})});(b=b.after)?f(b):(console.log(c),console.log("you can copy/paste json object from console.. using chrome copy(). First right click object > store as global ..then copy(temp1).. temp1 is usually the name given to global var"),
confirm("Do you want to Download it? ...alternatively check console.")&&k(c))}function f(a){var e=g;a&&(console.log("got after",a),e=g+"&after="+a);setTimeout(function(){$.getJSON(e).done(function(a){console.log("new data!");h(a,c)})},200)}function k(a){a=JSON.stringify(a,null,2);a=new Blob([a],{type:"text/plain;charset=utf-8;"});a=URL.createObjectURL(a);$("<a>").attr({href:a,download:"redditSaveds"})[0].click()}var c=[],g="http://www.reddit.com/user/"+window.location.href.match(/user\/([^/]*)/)[1
@techsin
techsin / remove
Created May 27, 2015 02:49
remove
(function(){function k(a,b){var c=a.data;c.children.forEach(function(a){b.push(a.data.name)});(c=c.after)?e(c):(console.log(b),confirm("Delete All?")&&l(m()))}function m(){var a=0;f=setInterval(function(){n(a++);!d.length>a&&clearInterval(f)},200)}function n(a){$.ajax({url:"http://www.reddit.com/api/unsave",type:"post",data:{id:d[a]},headers:{"X-Modhash":g},success:function(){console.log("delete",a);0==a%10&&console.log("Eats a potato chip")}})}function e(a){var b=h;a&&(console.log("got after",a),
b=h+"&after="+a);setTimeout(function(){$.getJSON(b).done(function(a){k(a,d)})},200)}function l(a){$.getJSON("http://www.reddit.com/api/me.json").done(function(b){g=b.data.modhash;a()})}var d=[],g=null,h="http://www.reddit.com/user/"+window.location.href.match(/user\/([^/]*)/)[1]+"/saved.json?limit=100";(function(){if(!jQuery){var a=void 0,a=document.createElement("script");a.type="text/javascript";a.src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";document.getElementsByTagName("head")[0].append
arr = [1,2,3,4]
l = arr.length -1
while l<0 do
puts arr[l]
l = l-1
end
sentence = <<-something
Steven likes the movies. Blake likes to ride his bike but hates movies.
Blake is taller than steven. Steven Steven is a great teacher.
something
counter = Hash.new(0)
sentence.gsub!(".","").split(" ").each do |word|
counter[word] += 1
end
@techsin
techsin / cost
Last active August 29, 2015 14:26
sentence = <<-something
Steven likes the movies. Blake likes to ride his bike but hates movies.
Blake is taller than than than steven. Steven Steven is a great teacher.
something
counter = Hash.new(0)
sentence.gsub!(".","").split(" ").each do |word|
counter[word] += 1
end
sentence = <<-something
Steven likes the movies. Blake likes to ride his bike but hates movies.
Blake is taller than than than steven. Steven Steven is a great teacher.
something
counter = Hash.new(0)
sentence.gsub!(".","").split(" ").each do |word|
counter[word] += 1
end
@techsin
techsin / string
Created August 28, 2015 14:32
weird string
enabled_engage_types=3&fexp=9408710,9409069,9415365,9415485,9416023,9416126,9417707,9418153,9418448,9418625&loeid=9418625&token=vjVQa1PpcFN554nlNgYMuruOnAL3SYvB4F2MDKxP8cg=&cos=Macintosh&sw=1.0&plid=AAUeX39qhypudzsN&pltype=content&of=KAbBkFJChwlxHcxKF1RLog&keywords=Gallium,aluminum,coke,can,alloy&mpvid=H_fm5L8--31Z8V9U&enablecsi=1&cbr=Chrome&cc3_module=1&ttsurl=http://www.youtube.com/api/timedtext?v=FaMWxLCGY0U&expire=1440795591&sparams=caps%2Cv%2Cexpire&signature=1043630DDD92B8DE125D22DA1EAD04E688B59875.2547FBA5374C91AEAEE4863125F4F2ED50BF0503&hl=en_US&caps=&key=yttt1&iurlsd=http://i.ytimg.com/vi/FaMWxLCGY0U/sddefault.jpg&user_gender=m&cl=101619811&iv3_module=1&has_cc=True&ldpj=-5&tmi=1&iurlsd_webp=http://i.ytimg.com/vi_webp/FaMWxLCGY0U/sddefault.webp&video_id=FaMWxLCGY0U&show_content_thumbnail=True&vm=CAE&ad_device=1&cc_fonts_url=http://s.ytimg.com/yts/swfbin/player-vflGhXt5C/fonts708.swf&gut_tag=/4061/ytunknown/main&ad_flags=0&allow_html5_ads=1&cc_module=http://s.ytimg.com/yts/swfbin/player-vflGhXt5C/subti
@techsin
techsin / require-js-discussion.md
Created December 5, 2015 07:07 — forked from desandro/require-js-discussion.md
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.