Skip to content

Instantly share code, notes, and snippets.

Yehonathan Sharvit viebel

Block or report user

Report or block viebel

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 reagent-attributes
(require '[reagent.core :as reagent])
(def styles {:style {:color "red"}})
(defn hello []
[:div styles
"Hello CSS"])
(reagent/render [hello] js/klipse-container)
@viebel
viebel / sigma-3.re
Created Nov 15, 2017
Sigma in reason 3
View sigma-3.re
let rec sigma (f, s) =
switch (s) {
| [] => 0
| [x, ...l] => f (x) + sigma (f, l)
};
let () = Js.log (sigma ((fun (x) => x * x), [1, 2, 3]));
@viebel
viebel / sigma.re
Created Oct 5, 2017
Sigma in reason
View sigma.re
let rec sigma f s =>
switch s {
| [] => 0
| [x, ...l] => f x + sigma f l
};
let () = Js.log (sigma (fun x => x * x) [1, 2, 3]);
@viebel
viebel / sigma.ml
Created Oct 5, 2017
Sigma in Ocaml
View sigma.ml
let rec sigma f = function
| [] -> 0
| x :: l -> f x + sigma f l;;
Js.log (sigma (fun x -> x * x) [1; 2; 3]);;
View react-canvas.js
class MyCanvas extends React.Component {
constructor(props) {
super(props)
this.state = {value: ''}
this.handleClick = this.handleClick.bind(this)
}
componentDidMount() {
this.render()
View react-text-input.js
class TextInput extends React.Component {
constructor(props) {
super(props)
this.state = {value: ''}
this.handleChange = this.handleChange.bind(this)
}
handleChange(event) {
this.setState({value: event.target.value})
View tic-tac-toe-ramda.js
class Board extends React.Component {
constructor() {
super();
this.state = this.vanillaState();
}
vanillaState () {
return {squares: Array(9).fill(null),
xIsNext: true,
winner: null};
}
View klipse-re-frame.cljs
(ns simple.core
(:require [reagent.core :as r]
[re-frame.core :as rf]))
(rf/reg-event-db
:initialize
(fn [_ _]
{:loading? true}))
(rf/reg-event-db
@viebel
viebel / index.js
Created May 5, 2017
requirebin sketch
View index.js
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const { check, gen, property } = require('testcheck');
const result = check(
property(
gen.int,
x => x - x === 0
)
View wallpaper.cljs
(defn create-canvas []
(set!
(.-innerHTML js/klipse-container)
"<canvas id='canvas' width='500px' height='500px'/>")
(js/document.getElementById "canvas"))
(defn make-cell [canvas x y color]
(let [ctx (.getContext canvas "2d")]
You can’t perform that action at this time.