Skip to content

Instantly share code, notes, and snippets.

Jimmy Tang talyian

Block or report user

Report or block talyian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am talyian on github.
  • I am talyian (https://keybase.io/talyian) on keybase.
  • I have a public key ASDR2l3g4aL0kQBiQKSM6P7XXVJNmdC2lz5sYYqMog3DOwo

To claim this, I am signing this object:

View gist:bdc10c7a77f4488aeb988ddcf943459a
// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by Reed Adams
// *reset*
open System
type Node =
@talyian
talyian / mandelbrot.html
Created Jun 13, 2017
Mandelbrot set in WebGL
View mandelbrot.html
<style>body { background: black; } #cv { display:block; margin:auto; }</style>
<canvas id='cv' width='800' height='800'></canvas>
<script id=frag type='x-shader/fragment'>
precision highp float;
varying vec2 _pos;
void main() {
vec2 c = _pos * 1.5 - vec2(0.7, 0), z;
for(int i = 0; i < 64; i++) {
z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
gl_FragColor = vec4(vec3((float(i) - log(log(length(z)))) / 64.0), 1);
View door_opener.ino
#include <ESP8266WiFi.h>
const int BUZZER_INPUT_IO = 5;
const int DOOR_OUTPUT_IO = 4;
const int LED_IO = 0;
enum { STARTING, READY, NOTIFYING, OPENING };
void setup() {
Serial.begin(115200);
@talyian
talyian / arithmetic
Last active Jun 30, 2017
Not a good interview problem
View arithmetic
EVAL=(lambda F,B,V,P,T:lambda e:F(T(e),F,P,B(B,V))[0])(
lambda t,f,p,b: [p(p,t,(lambda x:b(('+','-'),b(('*','/'),x))))],
lambda b,e: lambda ops,t,i=0: t if i >= len(t) else b(b,e)(ops,(t.__setslice__(i-1,i+2,[e(t[i],t[i-1],t[i+1])]) or t),i) if t[i] in ops else b(b,e)(ops,t,i+1),
lambda o,x,y: {'+':lambda a,b:a+b, '-':lambda a,b:a-b, '*':lambda a,b:a*b, '/':lambda a,b:a/b}[o](float(x), float(y)),
lambda p, t, f: f((lambda s,e:t.__setslice__(s,e+1,[p(p,t[s+1:e], f)]) or t)(t.index('('),len(t)-1-t[::-1].index(')')) if '(' in t else t)[0],
lambda e: [x for x in __import__('re').split('(\\d+|.)', e.replace(' ', '')) if x],
)
print EVAL("3 - 5 - 4 - 3");
print EVAL("3 * 5 + 4 / 3");
print EVAL("3 * (5 + 4) / 2");
View OpenTK Texturing example
#r "System.Drawing"
#r "OpenTK"
open OpenTK
open OpenTK.Graphics
open OpenTK.Graphics.OpenGL4
let window = new GameWindow (400,400,
GraphicsMode.Default, "",
GameWindowFlags.Default,
DisplayDevice.Default,
@talyian
talyian / getresolution.fsx
Created Sep 30, 2017
WinGDI Get All supported Monitor Resolutions
View getresolution.fsx
#nowarn "9"
open System
open System.Runtime.InteropServices
[<StructLayout(LayoutKind.Sequential)>]
type DEVMODEInfo = struct
[<MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)>]
[<DefaultValue>] val mutable dmDeviceName : string
[<DefaultValue>] val mutable dmSpecVersion: int16;
[<DefaultValue>] val mutable dmDriverVersion: int16;
@talyian
talyian / AdventOfCode2017
Last active Dec 11, 2017
Advent of Code 2017 Solutions.
View AdventOfCode2017
Advent of Code 2017 Solutions
@talyian
talyian / mono.log
Last active Feb 23, 2018
Installing Mono on Debian Wheezy
View mono.log
jimmy@4f9659dd76f5:~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.I6Cq8DlByE --trustdb-name /etc/apt//trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-jessie-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-jessie-security-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-jessie-stable.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-stable.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-stable.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: requesting key D3D831EF from hkp server keyserver.ubuntu.com
gpg: /etc/apt//trustd
@talyian
talyian / fibonacci_nim.asm
Created Sep 28, 2018
Disassembly of nim fibonacci solutoin
View fibonacci_nim.asm
0000000000001640 <fib_SpYa5EuiU0areDDc1bSasA(unsigned long long)>:
1640: 48 83 ff 01 cmp $0x1,%rdi
1644: b8 01 00 00 00 mov $0x1,%eax
1649: 77 05 ja 1650 <fib_SpYa5EuiU0areDDc1bSasA(unsigned long long)+0x10>
164b: f3 c3 repz retq
164d: 0f 1f 00 nopl (%rax)
1650: 41 57 push %r15
1652: 41 56 push %r14
1654: 4c 8d 77 fe lea -0x2(%rdi),%r14
1658: 41 55 push %r13
You can’t perform that action at this time.