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
root@production:~# sudo /etc/init.d/postgresql start | |
* Starting PostgreSQL 9.1 database server * The PostgreSQL server failed to start. Please check the log output: | |
2014-03-18 00:39:51 EDT FATAL: could not create shared memory segment: Cannot allocate memory | |
2014-03-18 00:39:51 EDT DETAIL: Failed system call was shmget(key=5432001, size=430235648, 03600). | |
2014-03-18 00:39:51 EDT HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space, or exceeded your kernel's SHMALL parameter. You can either reduce the request size or reconfigure the kernel with larger SHMALL. To reduce the request size (currently 430235648 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections. | |
The PostgreSQL documentation contains more information about sha |
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
# An interactive game where the computer can learn to recognize | |
# more animals! | |
# Not sure if this is best practice for clarity, but i kept the | |
# data structure more like data rather than objects with methods | |
# so the recursion looks cleaner. | |
# an animal, like a dog or a cat | |
class Animal: | |
def __init__(self, animal): |
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
# you can copy/paste the code to here and run it in browser | |
# http://www.tutorialspoint.com/execute_julia_online.php | |
# a simple sigmoid shrink function that wraps x to a range between 0 and 1 | |
shrink_fun(x) = 1 / (1 + e^-x) | |
# a random function generator, | |
# it makes a function that maps x to a random point between 0 and 1 | |
function gen_fun() | |
n = -1.0 + 2*rand() # a random number between -1 and 1 |
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
# rational approximation, approximate a ratio with a rational number n / d | |
function rational_approx(ratio::Float64, tol::Float64) | |
# given a list of values for a continued fraction | |
# reconstruct as a simple fraction n / d | |
function re_construct(fract_list) | |
rev_list = reverse(fract_list) | |
n = rev_list[1] | |
d = 1 | |
for x in rev_list[2:end] | |
new_n = n * x + d |
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
batch_size = 1 | |
input_size = 2 | |
num_units = 3 | |
input_length = 8 | |
sess = tf.Session() | |
with tf.variable_scope("root", initializer=tf.constant_initializer(0.5)) as scope: |
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
import tensorflow as tf | |
import numpy as np | |
if __name__ == '__main__': | |
np.random.seed(1) | |
# the size of the hidden state for the lstm (notice the lstm uses 2x of this amount so actually lstm will have state of size 2) | |
size = 1 | |
# 2 different sequences total | |
batch_size= 2 | |
# the maximum steps for both sequences is 10 |
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
======= | |
def oddTuples (x0 ): | |
x1 =() | |
for x2 in range (len (x0 )) | |
if x2 %2==0: | |
x1 =x1 +x0 [x2 ] | |
return x1 | |
def oddTuples (x0 ): | |
x1 =() |
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
=========== put this in timeout.py ============== | |
from functools import wraps | |
import errno | |
import os | |
import signal | |
class TimeoutError(Exception): | |
pass |
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
def f(x): | |
while x == x: | |
if 4 == 3: | |
x = 3 | |
print f([1,2,3,4,5]) |
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
# how much exp if I catch 2 pidgeys and 4 ratatas? | |
# here 2 pidgey is expressed as (2, 12) where 2 is number of pidgey | |
# and 12 is how many candy it takes for a pidgey to evolve | |
# the same goes to ratata, 4 ratatas, and a ratata takes 25 candies | |
caught = [(1, 400)] | |
# are you using egg? True or False | |
lucky_egg = False | |
OlderNewer