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
/* Problem: Find # of occurrences of a substring in a given input string | |
Example Output: | |
Test string: abcdabceabcfabcabcd | |
Substring count for abc:5 | |
Substring count for abcd:2 | |
*/ | |
public class CountSubs { | |
public static void main(String[] args) { | |
String testString = "abcdabceabcfabcabcd"; |
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
############################ | |
# Push notifications script | |
############################ | |
read -d '' String <<"EOF" | |
require "net/https" | |
require "socket" | |
url = URI.parse("https://api.pushover.net/1/messages.json") | |
req = Net::HTTP::Post.new(url.path) |
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
auto lo | |
iface lo inet loopback | |
iface eth0 inet dhcp | |
auto wlan0 | |
allow-hotplug wlan0 | |
iface wlan0 inet manual | |
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf | |
iface default inet dhcp |
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
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev | |
update_config=1 | |
network={ | |
ssid="__SSID__" | |
proto=RSN | |
key_mgmt=WPA-PSK | |
pairwise=CCMP TKIP | |
group=CCMP TKIP | |
psk="__PASSWORD__" |
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
{ | |
"id":"Barack Obama\tPERSON", | |
"description":"Barack Obama", | |
"image":null, | |
"type":"entity", | |
"children":[ | |
{ | |
"relationshipName":"tweetedBy", | |
"values":[ | |
{ |
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
{"type":"entity","image":null,"description":"Barack Obama","children":[{"values":[{"type":"user","image":"http:\/\/a0.twimg.com\/profile_images\/1261305267\/2012_normal.jpg","description":"@President","weight":"0.214285714285714","id":260537964},{"type":"user","image":"http:\/\/a0.twimg.com\/profile_images\/1115589019\/Paul_Barratt_photo_3_normal.jpg","description":"@phbarratt","weight":"0.0714285714285714","id":185614627},{"type":"user","image":"http:\/\/a0.twimg.com\/profile_images\/1189622627\/twitter_normal.jpg","description":"@SenJohnMcCain","weight":"0.1","id":19394188},{"type":"user","image":"http:\/\/a0.twimg.com\/profile_images\/3062422539\/39594d1aa231a04a532a7c98b0951e76_normal.jpeg","description":"@michellemalkin","weight":"0.115384615384615","id":15976697},{"type":"user","image":"http:\/\/a0.twimg.com\/profile_images\/63871979\/twittericon_normal.jpg","description":"@SpaceflightNow","weight":"0.125","id":17217640},{"type":"user","image":"http:\/\/a0.twimg.com\/profile_images\/791192176\/memeo_ii |
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
search_seed = ['term1','term2'...'ternN'] # implement this as a queue | |
sentence_count = 0; | |
sentences = [] | |
while(sentence_count < 150000){ | |
# get search term to use for this iteration | |
term = initial_seed.dequeue() | |
# Given a search term, get related sentences | |
new_sentences = getBingSentences(term) |
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
num_iterations = 20 | |
num_threads = 4 | |
# Try counting to 1 million on 4 separate threads 20 times | |
total_time = 0.0 | |
num_iterations.times do |iter| | |
threads = [] | |
t_0 = Time.now | |
for i in 1..num_threads | |
threads << Thread.new(i) { |t| |
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
# used to call java code | |
require 'java' | |
# 'java_import' is used to import java classes | |
java_import 'java.util.concurrent.Callable' | |
java_import 'java.util.concurrent.FutureTask' | |
java_import 'java.util.concurrent.LinkedBlockingQueue' | |
java_import 'java.util.concurrent.ThreadPoolExecutor' | |
java_import 'java.util.concurrent.TimeUnit' |
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
# Array Method for computing fibbonacci number | |
def fib(n) | |
return n if n < 2 | |
vals = [0, 1] | |
(n-1).times do | |
vals.push(vals[-1] + vals[-2]) | |
end | |
return vals.last | |
end |
OlderNewer