Skip to content

Instantly share code, notes, and snippets.

Avatar
😰
Working from home

Dmitry Salnikov grapefroot

😰
Working from home
View GitHub Profile
View jupyter_animate.py
from IPython.display import display
from JSAnimation.IPython_display import display_animation
from matplotlib import animation
def run_env_steps(env, num_steps=1000):
env.reset()
frames = []
for _ in range(num_steps):
# Render into buffer.
# You will still see the window.
View bullshit.c
# 1 "chia.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "chia.c"
# 49 "chia.c"
int N=0,_,O=328,l=192,y=4,Y[80][64]={0},I;struct LameJavaApp
{
@grapefroot
grapefroot / torchinstall
Created Jul 18, 2015
Torch installation script
View torchinstall
curl -sk https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; ./install.sh
View gist:58087c1de1a8bc2ef52d
su-
apt-get install cabal-install && clementine
cabal install xmonad && xmobar --flags="all_extensions"
@grapefroot
grapefroot / maxSubArray.py
Created Jun 4, 2015
Max sum of contiguous subarray
View maxSubArray.py
#based on idea that none of the prefixes of
#maximal sum array can be negative(interesting, isn't it)
def maxSubArray(self, A):
cursum = 0
maxsum = -999999999999
for item in A:
cursum += item
maxsum = max(cursum, maxsum)
if cursum < 0:
cursum = 0
@grapefroot
grapefroot / xgb.py
Created Apr 21, 2015
XGboost usage example
View xgb.py
param = {}
param['booster'] = 'gbtree'
param['objective'] = 'multi:softprob'
param['eval_metric'] = 'mlogloss'
param['num_class'] = 9
param['silent'] = 1
param['nthread'] = 1
num_round = 5000
plst = list(param.items())
@grapefroot
grapefroot / frequences.fsx
Created Apr 4, 2015
calculate character relevance based on some metric.
View frequences.fsx
open System
open System.IO
open Microsoft.FSharp.Core
let ReadLines fn =
seq { use inp = File.OpenText fn in
while not(inp.EndOfStream) do
yield(inp.ReadLine())
}
View 232.cpp
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
struct pt {
double x, y;
pt operator- (pt p) {
@grapefroot
grapefroot / jdk-install
Created Mar 26, 2015
intuitive jdk installation
View jdk-install
su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer
exit
View gist:c4fd3f1d38a1996110de
import Data.List
maximum' :: (Ord a) => [a] -> a
maximum' [] = error "maximum of empty list"
maximum' [x] = x
maximum' (x:xs) = max x (maximum' xs)
replicate' :: (Num i, Ord i) => i -> a -> [a]
replicate' n x
| n <= 0 = []