Skip to content

Instantly share code, notes, and snippets.

View nbeloglazov's full-sized avatar

Mikita Belahlazau nbeloglazov

View GitHub Profile
@nbeloglazov
nbeloglazov / rhino_script.js
Last active July 11, 2020 22:05
setTimeout, clearTimeout, setInterval, clearInterval implementations for Rhino that works in 1.7R4
var setTimeout, clearTimeout, setInterval, clearInterval;
(function () {
var executor = new java.util.concurrent.Executors.newScheduledThreadPool(1);
var counter = 1;
var ids = {};
setTimeout = function (fn,delay) {
var id = counter++;
var runnable = new JavaAdapter(java.lang.Runnable, {run: fn});
(ns mouse-example
(:require [quil.core :as q]))
(def w 1000)
(def h 1000)
(def acc 500)
(let [id (atom 0)]
(defn next-id []
(swap! id inc)))
@nbeloglazov
nbeloglazov / gist:7920049
Last active December 31, 2015 02:19
Update/draw separation
(ns example
(:require [quil.core :refer :all]))
(def initial-state
{:ball-x 200
:ball-y 100
:speed-x 10
:speed-y 2
:hit 0
@nbeloglazov
nbeloglazov / two_screen.lua
Created October 25, 2013 21:29
Two screen config for lua.
-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
-- My some helpful functions
require("util")
@nbeloglazov
nbeloglazov / actors.clj
Last active December 19, 2015 03:39
actors
(def ^:dynamic *self*)
(def ^:dynamic *sender*)
(defn process [f sender message]
(binding [*self* *agent*
*sender* sender]
(f message) f))
(defn tell [actor message]
(send actor process *self* message))
Overridden callMethods
Default callMethods
Overridden callMethods2
Expected:
Overridden callMethods
Overridden callMethods
Overridden callMethods2
@nbeloglazov
nbeloglazov / salesman.clj
Created August 15, 2012 09:17 — forked from djanatyn/salesman.clj
salesman
(defn move-to-front [first others]
"Moves an item to the front of the list"
(cons first (remove #(identical? first %) others)))
(defn first-level [list]
"Returns a list of all first-level permutations."
(map #(move-to-front % list) list))
(defn permute-deeper [depth list]
"Takes a list and a depth. Ignores the first few items according to the depth, and returns a list of all permutations for the rest."
(let [head-of-list (take depth list)
rest-of-list (drop depth list)
@nbeloglazov
nbeloglazov / gist:1351279
Created November 9, 2011 12:17
Apllication context
package com.geekalarm.android;
import android.content.Context;
public class Application extends android.app.Application {
private static Context context;
public void onCreate(){
context=getApplicationContext();
def can_modify?
if params[:id] == current_user.id.to_s
@user = current_user
else
redirect_to user_path(params[:id])
end
end