This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
last = 1 | |
def num1(num) | |
result = 0 | |
while num > 0 | |
if num % 10 == 1 | |
result += 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package se.fnord.android.layout; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
/** | |
* ViewGroup that arranges child views in a similar way to text, with them laid | |
* out one line at a time and "wrapping" to the next line as needed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var httpUrl = 'http://www.google.com/reader'; | |
var httpsUrl = 'https://www.google.com/reader'; | |
if (0 === tab.url.indexOf(httpUrl)) { | |
chrome.tabs.update(tab.id, {url: tab.url.replace(httpUrl, httpsUrl)}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
function checkForHttpAccessToGoogleReader(tabId, changeInfo, tab) { | |
var httpUrl = 'http://www.google.com/reader'; | |
var httpsUrl = 'https://www.google.com/reader'; | |
if (0 === tab.url.indexOf(httpUrl)) { | |
chrome.tabs.update(tab.id, {url: tab.url.replace(httpUrl, httpsUrl)}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
MTStatusBarOverlay *overlay = [MTStatusBarOverlay sharedInstance]; | |
overlay.animation = MTStatusBarOverlayAnimationShrink; | |
[overlay showWithMessage:@"Loading..."]; | |
[NSThread detachNewThreadSelector:@selector(loadFromServer) toTarget:self withObject:nil]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class Fixnum | |
alias :original_add :+ | |
def +(another) | |
original_add(another).original_add(1) | |
end | |
end | |
puts "1 + 1 = #{1+1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "yaml" | |
# make sure you have dump cookies to xunlei-cookies.txt | |
YAML.load_file("all_files.yml").each do |file| | |
cmd = "wget --load-cookies=xunlei-cookies.txt '#{file[:url]}' -c -O '#{file[:name]}'" | |
system(cmd) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.1-Introduction-Welcome.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.b-Introduction-WhatIsMachineLearning.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.3-Introduction-SupervisedLearning.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.d-Introduction-UnsupervisedLearning.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.1-LinearRegressionWithOneVariable-ModelRepresentation.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.2-LinearRegressionWithOneVariable-CostFunction.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.3-LinearRegressionWithOneVariable-CostFunctionIntuitionI.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.4-LinearRegressionWithOneVariable-CostFunctionIntuitionII.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.5-LinearRegressionWithOneVariable-GradientDescent.mp4 | |
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.6-LinearRegressionWithOneVariabl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# TODO: replace your-hostname-here.com and path_to_your_rwget_folder | |
if [ $# -lt 1 ] ; then | |
echo "usage: rwget URL" | |
exit 1 | |
fi | |
filename=`ssh your-hostname-here.com URL=$1 'bash -s' << 'ENDSSH' | |
cd path_to_your_rwget_folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "uri" | |
require "open-uri" | |
require "nokogiri" | |
def extract_flv(page_url) | |
url = nil | |
open(page_url) { |page| page.read }.each_line do |line| | |
url = URI.unescape($1) if line =~ /to\.addVariable\(\"video_url\",\"(.*)\"\)/ |
OlderNewer