Skip to content

Instantly share code, notes, and snippets.

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=frame-nopass.pdf -c .setpdfwrite -f frame.pdf
@masters3d
masters3d / statistics code.py.py
Created May 25, 2014 06:45
statistics code.py
#standard deviation
data=[3,3,3,3,3]
mean=3
dataminus=[(each-mean)**2 for each in data]
variance= sum(dataminus)/len(data)
print dataminus
print variance
print variance**.5
@masters3d
masters3d / statistics code.py.py
Created May 25, 2014 20:36
statistics code.py
#standard deviation
data=[0,1]
mean=(sum(data)+.0000)/len(data)
dataminus=[(each-mean)**2 for each in data]
variance= sum(dataminus)/len(data)
#print dataminus
print "this is the varience"
print variance
print
print "this is the standard div"
@masters3d
masters3d / gist:32400bf9e2dd17830690
Created September 16, 2014 03:28
swift scanner
let altStringToSearch:NSString = "I want to make a cake and then prepare coffee"
let altSearchTerm:NSString = "cake"
let altScanner = NSScanner(string: altStringToSearch)
var altResult:NSString?
altScanner.scanUpToString(altSearchTerm, intoString:&altResult)
println(altResult!)
@masters3d
masters3d / gist:8ba8006123a393b16352
Created September 17, 2014 04:19
Learning swift here. Code not working yet.
import UIKit
//TO DO: Need to add third pass to check if words to be replaced overlap. Larger numbers take precedence.
//Swift-ify Inflationary English
extension Array {
func contains<T : Equatable>(obj: T) -> Bool {
let filtered = self.filter {$0 as? T == obj}
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>
// Public domain.
// Free to use.
// Use like this:
var world = "Hello, world!"
let convertedRange = world.convertRange(0..<5)
world.removeRange(convertedRange)
// Converts a regular range (0..5) to a proper String.Index range.
extension String {
// Playground - noun: a place where people can play
import UIKit
// Setup the calendar object
let calendar = NSCalendar.currentCalendar()
// Set up date object
let date = NSDate()
@masters3d
masters3d / gist:7427a1f7de4353f7bf71
Created January 20, 2015 07:13
problems compare
import json
import urllib2
pythonParsedList = json.load(urllib2.urlopen('https://raw.githubusercontent.com/exercism/xpython/master/config.json'))
swiftParsedList = json.load(urllib2.urlopen('https://raw.githubusercontent.com/exercism/xswift/master/config.json'))
haskellParsedList = json.load(urllib2.urlopen('https://raw.githubusercontent.com/exercism/xhaskell/master/config.json'))
csharpParsedList = json.load(urllib2.urlopen('https://raw.githubusercontent.com/exercism/xcsharp/master/config.json'))
#Python
@masters3d
masters3d / gist:cbb9160ace0a7dbfa981
Last active August 29, 2015 14:14
isEmptyOrWhiteSpace
extension String {
var isEmptyOrWhiteSpace:Bool { get {
return self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()).isEmpty
}}}