This file contains hidden or 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
// client/codepad.html | |
<template name="page"> | |
{{#if any_page_selected}} | |
{{#with page}} | |
<h2>{{name}}</h2> | |
<textarea id="page_content" class="input-xlarge" style="width: 100%;">{{content}}</textarea> | |
<div class="form-actions"> | |
<input type="button" class="btn btn-primary" value="Save" /> | |
<button class="btn">Cancel</button> | |
</div> |
This file contains hidden or 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
require 'term/ansicolor' | |
require 'tlsmail' | |
task :watch_mongo do | |
@notified = false | |
file = Tempfile.new('stat_watch') | |
begin | |
Thread.new('mongostat') do |
This file contains hidden or 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
# Excute by the following: | |
# bundle exec rake [email protected] GMAIL_PASSWORD=password watch_heroku | |
task :watch_heroku do | |
puts "need to set GMAIL_USERNAME and GMAIL_PASSWORD environment variables" unless (ENV['GMAIL_USERNAME'] && ENV['GMAIL_PASSWORD']) | |
@critical_notified = false | |
@warning_notified = false | |
@total_lines = 0 |
This file contains hidden or 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
from copy import deepcopy | |
def dig(hash,*keys): | |
""" | |
digs into an dict, if anything along the way is None, then simply return None | |
So instead of | |
entry['bids']['maxCpm']['amount']['microAmount'] | |
This file contains hidden or 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
import random | |
def all_perms(elements): | |
if len(elements) <=1: | |
yield elements | |
else: | |
for perm in all_perms(elements[1:]): | |
for i in range(len(elements)): | |
#nb elements[0:1] works in both string and list contexts | |
yield perm[:i] + elements[0:1] + perm[i:] |
This file contains hidden or 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
class User: pass | |
class Project: pass | |
class Assignment: pass | |
def current_user(): | |
return User() | |
def can(action,classes): | |
raise NotImplementedException |
This file contains hidden or 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
from multiprocessing import Process, Manager, Event | |
from time import sleep | |
def f(process_number, shared_array, kb_interupt): | |
print "starting thread: ", process_number | |
while not kb_interupt.is_set(): | |
try: | |
shared_array.append(process_number) | |
sleep(3) | |
except KeyboardInterrupt: |
This file contains hidden or 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
import { | |
Entity, | |
PrimaryGeneratedColumn, | |
Column, | |
OneToMany, | |
BeforeInsert, | |
OneToOne, | |
Connection | |
} from 'typeorm'; |
This file contains hidden or 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
@EntityRepository(Member) | |
export class MemberRepository extends Repository<Member> { | |
public async findOrCreate(user: User, account: Account) { | |
// ?? How do I get access to the connection ?? | |
const notebookRepo = connection.getRepository(Notebook); | |
// do stuff with notebookRepo | |
// then |
This file contains hidden or 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
// index.ts | |
import "reflect-metadata"; | |
import { ApolloServer } from 'apollo-server' | |
import {AccountResolver} from "./modules/account.resolver"; | |
import * as path from "path"; | |
import {buildSchema} from "type-graphql"; | |
import {createConnection, useContainer} from "typeorm"; | |
import {Container} from "typedi"; |
OlderNewer