Skip to content

Instantly share code, notes, and snippets.

View lynxluna's full-sized avatar
🎯
Focusing

Didiet lynxluna

🎯
Focusing
View GitHub Profile
@lynxluna
lynxluna / fb.clj
Last active August 29, 2015 14:05
Wrapping Facebook4j to Clojure
;; Wrapping facebook4j in Clojure
;; Please include org.facebook4j/facebook4j-core "2.1.0"]
;; in your project.clj
(ns com.ykode.social.fb ;; change the namespace as you wish
(:import [facebook4j Facebook FacebookException FacebookFactory]
[facebook4j.auth AccessToken]))
(defn- kw->perms
"Converting keyword array such as [:public_profile :email]
@lynxluna
lynxluna / github.clj
Created August 16, 2014 07:28
Rather Incomplete Github Wrapping Example from kohsuke's Java Github Library
;; Depends on
;; [org.kohsuke.github-api "1.56"]
;; [clj-time "0.8.0"]
;; Samples converting kohsuke's GH* objects to clojure map
;; may inefficient but it works
(ns com.ykode.social.github
(:import [org.kohsuke.github GitHub GHMyself GHUser GHRepository]
[java.net URL])
(:require [clj-time.format :as tf]
@lynxluna
lynxluna / fb-lite.clj
Created August 17, 2014 05:17
Minimalist Facebook Graph API Client
;; Depends on clj-http and cheshire
(ns com.ykode.social.fb-lite
(:require [clj-http.client :as client]
[cheshire.core :refer [parse-string]]))
(defn- fburl [ext] (str "https://graph.facebook.com/" ext))
(defn- auth-get
[access-token url]
import scala.collection.mutable.ListBuffer
import akka.actor.{Actor,ActorRef}
import akka.actor.Actor._
import akka.routing.{ Listeners, Listen }
//Represents a domain event
trait Event
//A builder to create domain entities
trait EntityBuilder[Entity] {
var idler = uv_idle_t()
uv_idle_init(uv_default_loop(), &idler)
uv_idle_start(&idler, { (_:UnsafeMutablePointer<uv_idle_t>) -> Void in print("Yay")})
print("Idling...")
uv_run(uv_default_loop(), UV_RUN_DEFAULT)
uv_loop_close(uv_default_loop())
@lynxluna
lynxluna / build.sh
Created October 12, 2015 10:49
Build Script
xcrun -v swiftc -emit-module -emit-library src/whiff.swift \
-sdk $(xcrun --show-sdk-path --sdk macosx) -module-name Haste \
-I deps/include -L deps/lib -luv -v \
-Xlinker -unexported_symbols_list -Xlinker symbols.exp -Xcc -O3 -Xcc -g0 -Xlinker -x
@lynxluna
lynxluna / build.gradle
Created November 16, 2015 13:41
Kotlin Template
buildscript {
ext.kotlin_version = "1.0.0-beta-1103"
repositories {
jcenter()
mavenCentral()
maven {
url 'http://oss.sonatype.org/content/repositories/snapshots'
}
}
dependencies {
@lynxluna
lynxluna / post3-reboot.S
Last active September 24, 2016 19:52
Rebooting
.code16 # 16-bit Assembly (real mode)
.text # Mulai section text
.set MAGIC, 0xAA55 # Macro untuk MAGIC number boot record
.globl BootEntry # Simbol Entry Point
BootEntry:
cli # Matikan interrupt
xorw %ax, %ax # AX = 0
movw %ax, %ds # DS = AX = 0
@lynxluna
lynxluna / UnsafeAllocate.java
Created February 5, 2017 17:17
Allocating Instance without calling constructor, just like you're doing with malloc()
import java.lang.reflect.Field;
import java.lang.reflect.Method;
final class InstanceFactory <T> {
public T unsafeAllocate(final Class<?> clazz) {
final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
final Field f = unsafeClass.getDeclaredField("theUnsafe");
f.setAccessible(true);
final Object unsafe = f.get(null);
final Method allocateInstance = unsafeClass.getMethod("allocateInstance", Class.class);
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=8em,minimum width=2em]
{
& \bullet \\
\bullet & \bullet \\
& \bullet \\};
\path[->] (m-2-1) edge [in=70,out=100,loop] node[auto](F) {$f$} ();
\path[->,draw] (m-2-1) edge [in=60,out=120,loop,distance=2cm] node[auto](G) {$g$} (m-2-1);
\path[->,draw] (m-2-1) to [in=40,out=140,loop,distance=4.5cm] node[auto](GCF) {$g\circ f$} (m-2-1);