Skip to content

Instantly share code, notes, and snippets.

@vbedegi
vbedegi / react-sortable-hoc-in-reagent.cljs
Last active Nov 29, 2017
using react-sortable-hoc in reagent
View react-sortable-hoc-in-reagent.cljs
(def react-sortable-hoc (aget js/window "deps" "react-sortable-hoc"))
(defn make-sortable-element-component [wrapped-component]
(let [sortable-element-factory (.-SortableElement react-sortable-hoc)]
(-> wrapped-component
r/reactify-component
sortable-element-factory
r/adapt-react-class)))
(defn make-sortable-container-component [wrapped-component]
@vbedegi
vbedegi / elm.cljs
Last active Apr 29, 2019
elm in cljs
View elm.cljs
; util
(defn tag-dispatch [dispatch tag]
(fn [msg]
(let [tagged (if (vector? tag)
(conj tag msg)
[tag msg])]
(dispatch tagged))))
; counter
View edx-module4.fs
open System
open System.IO
let gravity = 9.81
let angleOfReach speed distance = 0.5 * Math.Asin((gravity * distance) / Math.Pow(speed, 2.0))
let distanceTravelled speed angle = Math.Pow(speed, 2.0) * Math.Sin(2.0 * angle) / gravity
let angle x y = Math.Atan(y / x)
View edx-module3.fs
open System
let ratio = (1.0 + Math.Sqrt(5.0)) / 2.0
let inputInt (prompt: String) =
Console.WriteLine(prompt)
int (Console.ReadLine())
let inputFloat (prompt: String) =
Console.WriteLine(prompt)
View edx-module2.fs
open System
let rec queryForNonNegativeInt msg =
printf msg
let parsed, number = Int32.TryParse(Console.ReadLine());
if parsed then
if number < 0 then queryForNonNegativeInt msg
else number
else queryForNonNegativeInt msg
@vbedegi
vbedegi / handler.clj
Created Sep 28, 2014
Qarth sample with Ring
View handler.clj
(ns qartoy.handler
(:require [clojure.tools.logging :as log]
[ring.util.response :refer [redirect]]
[compojure.core :refer :all]
[compojure.handler :as handler]
[compojure.route :as route]
[qarth.oauth :as oauth]
[qarth.impl.facebook :refer :all]
[qarth.impl.google :refer :all]
[qarth.impl.github :refer :all]
@vbedegi
vbedegi / Main.sublime-menu
Created Jan 18, 2014
SublimeRepl user config for Clojure C:\Users\your-user-name\AppData\Roaming\Sublime Text 3\Packages\User\SublimeREPL\config\Clojure\Main.sublime-menu
View Main.sublime-menu
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
View core.async-lazy-sequence
(use 'clojure.core.async)
;this is the function you want to use
(defn lazy-channels [chs]
(lazy-seq (cons (let [ [v _] (alts!! chs)] v) (lazy-channels chs))))
;now for the tesging
(def chs [ (chan) (chan) (chan) ]) ; the channels can come from anywhere, here we are using three channels for testing
@vbedegi
vbedegi / Example1.cs
Created Mar 5, 2012
A transactional, concurrent queue for .Net
View Example1.cs
var queue = new TransactionalConcurrentQueue<int>();
using (var scope = new TransactionScope())
{
queue.Enqueue(1);
// won't happen
queue.Dequeue(x => Console.WriteLine(x));
scope.Complete();
@vbedegi
vbedegi / some.cs
Created Jan 5, 2012
decompiled lambda expression
View some.cs
IQueryable<<>f__AnonymousType0<string>> <>f_AnonymousType0s = Expression[] expressionArray = new Expression[1].Select<string,<>f__AnonymousType0<string>>(Expression.Lambda<Func<string, <>f__AnonymousType0<string>>>(Expression.New(expressionArray[0] = parameterExpression, expressionArray, new MethodInfo[] { (MethodInfo)MethodBase.GetMethodFromHandle(Name, <>f__AnonymousType0<string>) }), new ParameterExpression[] { parameterExpression }));