Skip to content

Instantly share code, notes, and snippets.

View trickster's full-sized avatar
🎯
Focusing

Sivaram Konanki trickster

🎯
Focusing
  • South Korea
  • 12:00 (UTC +09:00)
View GitHub Profile
@trickster
trickster / strrep.rb
Created August 26, 2012 11:48
THis is a public gist
class Array
def check_all_odd
self.each do |i|
if i.even?
return false
else
next
end
end
return true

This is temp file to share via gist.

@trickster
trickster / rust-python-cffi.md
Created February 2, 2018 07:33 — forked from seanjensengrey/rust-python-cffi.md
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes.

Based on http://harkablog.com/calling-rust-from-c-and-python.html (dead) which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes
@trickster
trickster / playground.rs
Last active March 3, 2018 04:26 — forked from anonymous/playground.rs
Rust code shared from the playground (Iterators)
/*
Iterators and all functions that operates on iterators, are lazy by default.
Executes on demand.
Here in we have `println` that executes the lazy expression that is `largest`.
*/
fn main() {
let a = [5,2,3,1,5,7,3];
@trickster
trickster / control.nim
Created March 5, 2018 15:18
control flow in Nim
import strutils, random
randomize()
let answer = rand(10)
while true:
echo "Guess the number?"
let guess = parseInt(stdin.readLine)
if guess < answer:
echo "Less than answer"
@trickster
trickster / perl-one-liners
Created March 16, 2018 00:49
Perl One-Liners
Useful One-Line Scripts for Perl Dec 03 2013 | version 1.10
-------------------------------- ----------- ------------
Compiled by Peteris Krumins (peter@catonmat.net, @pkrumins on Twitter)
http://www.catonmat.net -- good coders code, great reuse
Latest version of this file is always at:
http://www.catonmat.net/download/perl1line.txt
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
@trickster
trickster / zebra-logic.ss
Created March 23, 2018 14:51
Zebra logic in Scheme
; who owns the zebra
; 1 There are five houses.
; 2 The Englishman lives in the red house.
; 3 The Spaniard owns the dog.
; 4 Coffee is drunk in the green house.
; 5 The Ukrainian drinks tea.
; 6 The green house is immediately to the right of the ivory house.
; 7 The Old Gold smoker owns snails.
; 8 Kools are smoked in the yellow house.
@trickster
trickster / test.clj
Last active March 23, 2018 15:33
Learning Clojure (core.logic too)
(println "Hello")
(let [x 1
y 2]
(print "foo")
(str 1 2
3 4 5))
(defproject uncomp-1 "0.1.0-SNAPSHOT"
:description "Example project showcasing uncomplicate power"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.9.0"]
[uncomplicate/neanderthal "0.18.0" :exclusions [[org.jcuda/jcuda-natives]
[org.jcuda/jcublas-natives]]]]
:main ^:skip-aot uncomp-1.core
:target-path "target/%s"