Skip to content

Instantly share code, notes, and snippets.

@jbuda
jbuda / gist:0d28a712481135ff5944
Created July 31, 2014 07:54
Weinre android js script injection without having to change the physical html
webView.loadUrl(
"javascript:"+
"var script = document.createElement('script'); "+
"script.type = 'text/javascript'; "+
"script.src = 'http://XXXXXXXXX:XXXX/target/target-script-min.js#anonymous'; "+
"document.getElementsByTagName('head')[0].appendChild(script); "
);
@jbuda
jbuda / gist:9893487
Created March 31, 2014 14:25
Increment Build number on XCode project
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
@jbuda
jbuda / gist:9888066
Created March 31, 2014 08:44
Compiling 32/64 bit for devices and simulators for Objective-C and XCode
# folder vars
FOLDERNAME=${PROJECT_NAME}
LIBRARYNAME="lib${PROJECT_NAME}.a"
OUTPUTFOLDER=${SRCROOT}/build/${FOLDERNAME}
# make sure the output directory exists
mkdir -p "${OUTPUTFOLDER}"
# device / simulator builds
xcodebuild -project "${PROJECT_NAME}.xcodeproj" -configuration "Release" -sdk "iphoneos7.1" clean build ARCHS="armv7 armv7s" IPHONEOS_DEPLOYMENT_TARGET="5.0" TARGET_BUILD_DIR="${BUILD_DIR}/build-arm" BUILT_PRODUCTS_DIR="${BUILD_DIR}/build-arm"
@jbuda
jbuda / gist:7125948
Created October 23, 2013 20:18
Ruby - Day 3 - Seven Languages in Seven Weeks
module ActsAsCsv
class CsvRow
attr_accessor :header, :content
def initialize header,content
@header = header
@content = content
end
@jbuda
jbuda / gist:7061879
Created October 19, 2013 21:36
Ruby - Day 2 - Seven Languages in Seven Weeks
f = File.open("moon_wiki.txt")
f.each do |line|
if (line.grep(/moon/i).length > 0)
puts "Match on line #{f.lineno} - #{line}"
end
end
@jbuda
jbuda / gist:7061547
Created October 19, 2013 21:05
Ruby - Day 2 - Seven Languages in Seven Weeks
# update the tree initialiser to accept a nested structure with hashes and arrays
class Tree
attr_accessor :children, :node_name
def initialize(tree)
@node_name = tree.keys()[0]
@children = []
tree[tree.keys()[0]].each do |k,v|
@jbuda
jbuda / gist:7061047
Created October 19, 2013 20:22
Ruby - Day 2 - Seven Languages in Seven Weeks
# using each
values = []
[*(1..16)].each do |i|
values.push(i)
if (values.length == 4)
puts values.join(",")
values = []
end
@jbuda
jbuda / gist:7050316
Created October 19, 2013 00:37
Ruby - Day 1 - Seven Languages in Seven Weeks
n = rand(100)
input = gets.chomp.to_i
while (input != n) do
puts (input < n) ? "Too low" : "Too high"
input = gets.chomp.to_i
end
puts "Correct! The answer was #{n}"
@jbuda
jbuda / gist:7050311
Created October 19, 2013 00:37
Ruby - Day 1 - Seven Languages in Seven Weeks
10.times do |idx|
puts "This is the sentence number #{idx+1}"
end
@jbuda
jbuda / gist:7050294
Created October 19, 2013 00:35
Ruby - Day 1 - Seven Languages in Seven Weeks
10.times do
puts "janusz"
end