Skip to content

Instantly share code, notes, and snippets.

View fogonthedowns's full-sized avatar
👋

JZ fogonthedowns

👋
View GitHub Profile
#import "snapApi.h"
#import <RestKit/RestKit.h>
#import "Profile.h"
@interface snapApi ()
@property (nonatomic, strong) NSArray *profile;
@end
@implementation snapApi
@fogonthedowns
fogonthedowns / gist:51b8ec1b7976f38b0657
Created June 4, 2014 05:31
swift fibonacci number
// Playground - noun: a place where people can play
// swift fibonacci number
// Justin Zollars
// jz.io
import Cocoa
var answer = fib(5)
func fib(start: Int) -> Int {
class Hack
attr_accessor :possible, :array, :final_answer
def initialize
@possible = ["A","B","C","D"]
@array = []
@final_answer = []
self.generate
self.process_array
end
class City
attr_accessor :cities, :connections, :path, :total_time, :next_city, :count, :run_count, :nodes
PathBegins = "sf"
EndingTime = 1440 # 24 hours * 60
def initialize
@cities = ["bos", "nyc", "la", "sea", "jac", "chi", "phx", "med", "min", "gre", "oma", "dc", "mem", "den",
"abq", "dal", "dtw", "cha", "slc" ]
@connections = {
"sf"=>[["bos", 110], ["gre",32], ["slc", 23], ["la", 12], ["med",10]],
x = {"Alanine"=>7.4, "Arginine"=>4.2, "Asparagine"=>4.4, "Aspartic Acid"=>5.9, "Cystine"=>3.3,
"Glutamic Acid"=>5.8, "Glutamine"=>3.7, "Glycine"=>7.4, "Histidine"=>2.9, "Isoleucine"=>3.8,
"Leucine"=>7.5, "Lysine"=>7.2, "Methionine"=>1.8, "Phenylalanine"=>4.0, "Proline"=>5.0,
"Serine"=>8.0, "Threonine"=>6.2, "Tryptophan"=>1.3, "Tyrosine"=>3.3, "Valine"=>6.8,
"Stop Codons"=>0.1}
x.sort_by {|_key, value| value}
=>[["Stop Codons", 0.1], ["Tryptophan", 1.3], ["Methionine", 1.8], ["Histidine", 2.9],
["Tyrosine", 3.3], ["Cystine", 3.3], ["Glutamine", 3.7], ["Isoleucine", 3.8], ["Phenylalanine", 4.0],
x = {"Alanine"=>7.4, "Arginine"=>4.2, "Asparagine"=>4.4, "Aspartic Acid"=>5.9, "Cystine"=>3.3,
"Glutamic Acid"=>5.8, "Glutamine"=>3.7, "Glycine"=>7.4, "Histidine"=>2.9, "Isoleucine"=>3.8,
"Leucine"=>7.5, "Lysine"=>7.2, "Methionine"=>1.8, "Phenylalanine"=>4.0, "Proline"=>5.0,
"Serine"=>8.0, "Threonine"=>6.2, "Tryptophan"=>1.3, "Tyrosine"=>3.3, "Valine"=>6.8,
"Stop Codons"=>0.1}
# creates a sorted list of codons
sorted = x.sort_by {|_key, value| value}
=> [["Stop Codons", 0.1], ["Tryptophan", 1.3], ["Methionine", 1.8], ["Histidine", 2.9], ["Tyrosine", 3.3],
file_path = ARGV[0]
number_of_lines = ARGV[1] || 10
answer = {}
number_of_lines = number_of_lines.to_i
if file_path.nil?
puts "you must include a file path"
else
File.open(file_path).each_with_index do |line, index|
answer[index] = line
end
format:
db.nia.find({"BUDGET_START":{$nin : ['', undefined]}}).forEach( function(obj) {if (typeof(obj.BUDGET_START)!='object') {var datePt = obj.BUDGET_START.split('/');var dateEn = datePt[2] + '-' + datePt[0] + '-' + datePt[1];obj.BUDGET_START = new ISODate(dateEn);db.nia.save(obj);}});
then search:
db.nia.find({"BUDGET_START": {$gte: ISODate("2010-01-01T00:00:00.000Z"),$lt: ISODate("2010-12-30T00:00:00.000Z")}}).count()
ensure index:
var myApp = angular.module('myApp',[]);
myApp.controller('QuestionsController', ['$scope', '$http', function($scope, $http) {
var AUTH_TOKEN = $('meta[name=csrf-token]').attr('content');
var user_id = "1"
console.log(AUTH_TOKEN);
$http.defaults.headers.common['X-CSRF-Token'] = AUTH_TOKEN;
$http.defaults.headers.post["Content-Type"] = "application/json";
@fogonthedowns
fogonthedowns / gist:6fb4334442723002c5b7
Created October 3, 2014 01:50
oxidation #s for each atom in (NH4)2Ce(SO4)3
NH4 is (+1) (Oxidation number of N in NH4+ is -3 Oxidation number of each H in NH4+ is +1)
Ce is +3
SO4 is -2 ( Oxidation number of S is +6 and O is -2 in SO4)
You have 2 polyatomic ions in this. NH4 and SO4
NH4 is +1 (you will probably have to memorize common ions and this is very common.) Since NH4 is +1 you can look at each element individually. H is in group 1 (look across the periodic table. There are 8 long columns. Elements in group 1 tend to lose an electron. That makes them a positive number since they will have more protons than electrons. That would mean H is +1. N is in group 5. It usually is going to either lose 5 or gain 3. (All want 8 except for H and He that want 2). N must be negative to balance out the ion. Since H is +1 and you can see in NH4 that there are 4H's that means you have +4 for all the H in the ion. The ion totally is +1. 4 - 1= 3 So N gains electrons and is -3.
SO4 is a poly atomic ion that is -2. O and S are both in group 6. That means they want to lose 6 or gain 6. O is going