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
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
arr = [1,2,3,4]
l = arr.length -1
while l<0 do
puts arr[l]
l = l-1
end
@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
@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 / 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());
var that = this;
setTimeout(function(){
that.style.backgroundColor='red';
},1000);