Skip to content

Instantly share code, notes, and snippets.

View BinRoot's full-sized avatar

Nishant Shukla BinRoot

View GitHub Profile
@jgoosey
jgoosey / quine.hs
Last active August 12, 2020 17:22
Quine in Haskell, two implementations
--Haskell Quine
--Implementation 1
import Control.Monad
import Control.Monad.Instances
main = (putStr . ap (++) show)
"--Haskell Quine\n--Implementation 1\nimport Control.Monad\nimport Control.Monad.Instances\nmain = (putStr . ap (++) show) "
--Implementation 2
--main = putStrLn (s ++ show s) where s =
-- "--Haskell Quine\n--Implementation 2\nmain = putStrLn (s ++ show s) where s ="
@jfager
jfager / simple_server.rs
Last active December 18, 2015 09:59
Writing a websocket server in Rust, ran into an issue where the server would hang after a few connection attempts. Here's a minimal client/server; in the server, if you uncomment the separate spawned task on the default scheduler, the hang always happens. Putting that other task on its own thread makes everything work fine.
extern mod extra;
use std::{int,io,result};
use extra::{net,net_tcp,uv};
fn main() {
let (accept_port, accept_chan) = stream();
let (finish_port, finish_chan) = stream();
let addr = extra::net_ip::v4::parse_addr("127.0.0.1");
@AlexeyMK
AlexeyMK / d.py
Last active January 3, 2022 22:01
A version of Coffeescript's {name, age, location} translating to {name: name, age: age, location: location} for Python, using ast.py
def d(*args):
d_name = 'd'
import inspect
cur = inspect.currentframe()
calling_frame = inspect.getouterframes(cur)[1]
frameinfo = inspect.getframeinfo(calling_frame[0])
string = frameinfo.code_context[0].strip()
import ast
ast_module = ast.parse(string)
@Airblader
Airblader / py3lock.py
Created May 11, 2015 16:41
Obscure only actual windows for i3lock
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# vim:ts=2:sw=2:expandtab
import os
import xcb
from xcb.xproto import *
from PIL import Image
XCB_MAP_STATE_VIEWABLE = 2
@veggiemonk
veggiemonk / install_font_scp.sh
Created July 2, 2015 13:07
install source code pro font in Ubuntu 14.04.2
#!/bin/sh
echo "installing fonts at $PWD to ~/.fonts/"
mkdir -p ~/.fonts/adobe-fonts/source-code-pro
git clone https://github.com/adobe-fonts/source-code-pro.git ~/.fonts/adobe-fonts/source-code-pro
# find ~/.fonts/ -iname '*.ttf' -exec echo \{\} \;
fc-cache -f -v ~/.fonts/adobe-fonts/source-code-pro
echo "finished installing"
@b38tn1k
b38tn1k / tensorflowTutorialOne.py
Last active December 18, 2015 01:06
Google tensorflow tutorial 1 in a file with comments and stuff
import input_data
import tensorflow as tf
# http://www.tensorflow.org/tutorials/mnist/beginners/index.html
print '\033[93m' + 'Tutorial1 from:\nhttp://www.tensorflow.org/tutorials/mnist/beginners/index.html' + '\033[0m'
print 'MNIST INPUT DATA'
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
'PLACE HOLDERS'
# Make a placeholder / value to input on run
@vinhkhuc
vinhkhuc / simple_mlp_tensorflow.py
Last active December 22, 2021 11:52
Simple Feedforward Neural Network using TensorFlow
# Implementation of a simple MLP network with one hidden layer. Tested on the iris data set.
# Requires: numpy, sklearn>=0.18.1, tensorflow>=1.0
# NOTE: In order to make the code simple, we rewrite x * W_1 + b_1 = x' * W_1'
# where x' = [x | 1] and W_1' is the matrix W_1 appended with a new row with elements b_1's.
# Similarly, for h * W_2 + b_2
import tensorflow as tf
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split