Skip to content

Instantly share code, notes, and snippets.

@sasa1977
sasa1977 / conway2.ex
Last active March 12, 2018 16:14
Conway's Game of Life
# Works on Elixir 1.0.x
# Usage: just pust to `iex` shell, or run `elixir conway.ex`
defmodule Sum do
defstruct value: 0
def value(%Sum{value: value}), do: value
def add(%Sum{value: value} = sum, x) do
%Sum{sum | value: value + x}
@nickabal
nickabal / gist:0a3faaa45b76a53bfad76a748e27b58f
Created April 11, 2016 17:30
Set brightness via radeon_bl0 when redshift status changes
#!/bin/bash
# Set brightness via radeon_bl0 when redshift status changes (amdgpu,radeon)
### Set brihtness via xbrightness when redshift status changes
# Set brightness values for each status.
# Range from 1 to 255 is valid
brightness_day="255"
brightness_transition="120"
@bamanzi
bamanzi / chroot.sh
Last active May 16, 2018 19:56
chroot wrapper
NEWROOT=`dirname $(readlink -f $0)`
read -n1 -p "chroot to $NEWROOT? (y/n) :" ack
[ foo"$ack" == fooy ] || exit -1
echo " "
function mount_if_not() {
dir=$1
mount | grep $NEWROOT$dir >/dev/null
#!/usr/bin/env bash
# Time-stamp: <2017-04-21 17:44:04 kmodi>
# https://discuss.gohugo.io/t/auto-generate-file-name-based-on-title/4648/2?u=kaushalmodi
# This script uses the unofficial strict mode as explained in
# http://redsymbol.net/articles/unofficial-bash-strict-mode
#
# Also checks have been done with www.shellcheck.net to have a level of
# confidence that this script will be free of loopholes.. or is it? :)
#!/usr/bin/env bash
# Time-stamp: <2017-05-18 08:18:01 kmodi>
# Usage: ./mybuild.sh # Installs using origin/devel
# ./mybuild.sh --rev v0.17.0
# ./mybuild.sh --rev origin/master
set -euo pipefail # http://redsymbol.net/articles/unofficial-bash-strict-mode
IFS=$'\n\t'
#!/usr/bin/env bash
# Time-stamp: <2018-05-11 15:59:07 kmodi>
# Script to stow packages from ${STOW_PKGS_ROOT} to ~/stowed
# Usage: stow_it.sh (That's it; from any directory)
# This script uses the unofficial strict mode as explained in
# http://redsymbol.net/articles/unofficial-bash-strict-mode
# Also checks have been done with www.shellcheck.net to have a level of
@fogus
fogus / oops.dot
Created June 6, 2012 19:02
influence graph of oo languages -- this is not meant to be a complete time line. I'm mostly concerned with the root and inner nodes.
digraph G {
ranksep=1.0;
ratio=0.6;
LISP [color=Blue, shape=box, label="LISPs"];
ALGOL [color=Blue, shape=box, label="ALGOL-like\nLanguages"];
Modula [color=Blue, shape=box, label="Wirth's\nPascal-likes"];
Smalltalk [color=Blue, shape=box, label="Smalltalk-like\nLanguages"];
FP [color=Blue, shape=box, label="Functional\nProgramming\nLanguages"];
P [label="Prototype-based\nLanguages", color=Blue, shape=box];
@spdegabrielle
spdegabrielle / solar.rkt
Created May 23, 2017 20:27
solar sim using 2htdp/universe
#lang racket/base
(require 2htdp/universe 2htdp/image lang/posn)
; The gravitational constant G
(define G 6.67428e-11)
; Assumed scale: 100 pixels = 1AU
(define AU (* 149.6e6 1000))
(define SCALE (/ 250 AU))
(struct body (id px py vx vy mass radius color) #:mutable #:transparent) ;Structure of body
@rvause
rvause / fourdown.py
Created August 23, 2011 17:00
Python script to download images from a thread on 4chan
#!/usr/bin/env python
'''
fourdown.py
A simple script to grab links to images found on a page.
You can use as is for downloading images from thread on 4chan or you can
import FourDown and do what ever you want with it.
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 2a75365..b466ab2 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -81,6 +81,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <locale.h>
+#include <math.h>