Skip to content

Instantly share code, notes, and snippets.

@bytezen
bytezen / behaviors.py
Created July 20, 2018 14:33
Day4 - Seek Steering Behavior
from pygame.math import Vector2
import util
class Behavior:
NONE = 0
SEEK = 1
## id_map = {0:'NONE',1:'SEEK'}
##
## def __init__(self,entity,behavior_type):
@bytezen
bytezen / console_colors.sh
Created July 13, 2018 13:46 — forked from parvez/console_colors.sh
Console Colors
LF="\n"; CR="\r"
INVT="\033[7m"; NORM="\033[0m"; BOLD="\033[1m"; BLINK="\033[5m"
#UNDR="\033[2m\033[4m"; EOL="\033[0K"; EOD="\033[0J"
UNDR="\033[4m"; EOL="\033[0K"; EOD="\033[0J"
SOD="\033[1;1f"; CUR_UP="\033[1A"; CUR_DN="\033[1B"; CUR_LEFT="\033[1D"
CUR_RIGHT="\033[1C"
#-- ANSI code
SCR_HOME="\033[0;0H" #-- Home of the display
@bytezen
bytezen / spacemacs-cheshe.md
Created May 8, 2018 18:13 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers
@bytezen
bytezen / ports.js
Created September 10, 2017 05:19
Shanghai Elm headless port example from: peerreynders comment on https://gist.github.com/evancz/8521339
/* ports.js - Chrome 55.0.2883.95 (64-bit)
It is assumed that "this.Elm" is set
and valid for this IIFE (i.e. "Window.Elm.Shanghai"
was set by Shanghai.js beforehand).
*/
; (function() {
function connectElmWorker(elm) {
function logDockedCapacity (value) {
@bytezen
bytezen / decode.md
Created September 2, 2017 14:28 — forked from yang-wei/decode.md
Elm Json.Decode tutorial and cheatsheet

When receiving JSON data from other resources(server API etc), we need Json.Decode to convert the JSON values into Elm values. This gist let you quickly learn how to do that.

I like to follow working example code so this is how the boilerplate will look like:

import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=))

import Http
@bytezen
bytezen / RandomDemo.elm
Created June 29, 2017 13:13 — forked from pdamoc/RandomDemo.elm
RandomDemoPair
module RandomDemo where
import Html exposing (..)
import Html.Events exposing (onClick)
import Random exposing (int, generate)
import StartApp
import Effects exposing (Effects)
@bytezen
bytezen / permutations.js
Created June 22, 2017 21:11 — forked from wassname/permutations.js
Combinatorics permutatons and product in javascript using lodash.js (like python's itertools)
/**
* Lodash mixins for combinatorics
* Inspired by python itertools: https://docs.python.org/2.7/library/itertools.html
*
* Usage:
* permutations([0,1,2],2) // [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]]
* combinations([0,1,2],2) // [[0,1],[0,2],[1,2]]
* combinations_with_replacement([0,1,2],2)// [[0,0],[0,1],[0,2],[1,1],[1,2],[2,2]]
* product([0,1,2],[0,1,2]) // [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
*
@bytezen
bytezen / as_keith_midi.xtm
Created May 12, 2017 17:53 — forked from CircuV/as_keith_midi.xtm
Transscript of live performance based on Andrew Sorensen "A Study in Keith"
;;; as_keith_midi.xtm -- live performance
;; based on Andrew Sorensen "A Study in Keith" Impromptu performance
;; "A Study In Keith" is a work for solo piano (NI's Akoustik Piano)
;; by Andrew Sorensen inspired by Keith Jarrett's Sun Bear concerts.
;; Orginal code transposed to Extempore
;; http://extempore.moso.com.au
;;
;; Author: cv
;; Keywords: extempore, live-coding, impromptu, keith jarret
@bytezen
bytezen / JazzBach.rb
Created April 13, 2017 15:39 — forked from rbnpi/JazzBach.rb
Jazz Bach converted for Sonic Pi from a MuseScore using a processing script after rearranging the piano part into 9 separate parts. Requires Sonic Pi 2.11 for run_file command. Hear it at https://soundcloud.com/scrbn/jazzbach
#Jazz Bach converted for Sonic Pi by Robin Newman Jan 2017
#requires to be used with run_file "path/to/filename/JazzBach.rb"
#using Sonic Pi 2.11 or later
use_synth :piano
s=1;r=0.1
with_fx :reverb,room: 0.8,mix: 0.5 do
with_fx :level,amp: 1.2 do #overall boost
with_fx :level do |v| #dynamic control during the piece
p=0.5;mp=0.7;mf=1;f=1.2;ff=1.5
in_thread do
@bytezen
bytezen / talk.md
Created April 13, 2017 15:29 — forked from rbnpi/talk.md
Bett Show 2015 talk

Sonic Pi 2.2 at Bett 2015

This is a summary of a talk given at Bett 2015 on Sonic Pi

I started by playing excerpts from two programs, Scott Joplin Maple Leaf Rag, and a Percussion Generator, to illustrate different things Sonic Pi can do, and gave a brief description of Sonic Pi and the user interface, similar to section 1.2 of the built in tutorial, which is accessed by clicking the Help button.

I also showed how one of the example programs "Idm Breakout" could be copied and played. Then I used the following program sections to develop a code to play the round Frere Jaques

##Making sounds