Skip to content

Instantly share code, notes, and snippets.

View madis's full-sized avatar
🧑‍💻
code mode

Madis Nõmme madis

🧑‍💻
code mode
View GitHub Profile
@tuzz
tuzz / state-transitions.rs
Created August 6, 2018 19:10
A Rust proof-of-concept from the August 2018 Rust meeting in London.
/* This is a proof-of-concept, inspired by clojure, that stores just the
* transitions between multiple Foo structs, rather than copying the entire
* struct's fields each time.
*/
#[derive(Default)] // <-- this derives Foo::default() which creates a Foo struct
// with a and b initialized to zero.
struct Foo {
a: u8,
b: u8,
@gavinheavyside
gavinheavyside / trivial_file_upload_service.rb
Created November 3, 2009 20:09
Trivial file upload service using Sinatra
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
post '/:name/:filename' do
userdir = File.join("files", params[:name])
@ivanoats
ivanoats / .railsrc
Last active August 11, 2020 09:33 — forked from gringocl/gist:8480696
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
@vparihar01
vparihar01 / nokogiri_libxml_homebrew_lion_installation.sh
Created June 25, 2013 07:01
How to fix: Nokogiri Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0. dlopen bundle.open. Using homebrew on lion to install nokogiri and lixml
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
ERROR -: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
@jamieparfet
jamieparfet / macOS-mojave-iso.sh
Last active February 11, 2023 19:16
Create an ISO from the mojave installer app
#!/bin/bash
# This assumes that the ~6GB mojave installer is in the /Applications folder.
# If it's not, just open the App Store, search Mojave, and you can download the installer file from there.
hdiutil create -o /tmp/mojave.cdr -size 6g -layout SPUD -fs HFS+J
hdiutil attach /tmp/mojave.cdr.dmg -noverify -mountpoint /Volumes/install_mojave
sudo /Applications/Install\ macOS\ mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/install_mojave
mv /tmp/mojave.cdr.dmg ~/Desktop/InstallSystem.dmg
hdiutil detach /Volumes/Install\ macOS\ mojave
@xzj
xzj / clojure.ctags
Created December 25, 2011 07:00
my .ctags(exuberant-ctags) for Clojure
--langdef=Clojure
--langmap=Clojure:.clj
--regex-clojure=/\([ \t]*create-ns[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/n,namespace/
--regex-clojure=/\([ \t]*def[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/d,definition/
--regex-clojure=/\([ \t]*defn[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/f,function/
--regex-clojure=/\([ \t]*defn-[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/p,private function/
--regex-clojure=/\([ \t]*defmacro[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/m,macro/
--regex-clojure=/\([ \t]*definline[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/i,inline/
--regex-clojure=/\([ \t]*defmulti[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/a,multimethod definition/
--regex-clojure=/\([ \t]*defmethod[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/b,multimethod instance/
@madvas
madvas / partial-right.clj
Created June 13, 2015 12:40
Clojure partial-right (Like a partial, but arguments are added to the end)
(defn partial-right
"Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with additional args + args."
([f] f)
([f arg1]
(fn [& args] (apply f (concat args [arg1]))))
([f arg1 arg2]
(fn [& args] (apply f (concat args [arg1 arg2]))))
([f arg1 arg2 arg3]
@thiagokokada
thiagokokada / test_runner.clj
Last active November 14, 2023 15:02
Babashka's test runner that dynamically discover the tests
#!/usr/bin/env bb
;; Inspired from https://book.babashka.org/#_running_tests
(require '[clojure.test :as t]
'[clojure.string :as string]
'[babashka.classpath :as cp]
'[babashka.fs :as fs])
(cp/add-classpath "src:test")

Why Flutter needs Clojure

”If you like Java, program in Java. If you like C#, program in C#. If you like Ruby, Swift, Dart, Elixir, Elm, C++, Python, or even C; by all means use those languages. But whatever you do, learn Clojure, and learn it well.” --- Uncle Bob (and several more tweets: 1, 2, 3).

There are lots of articles about Clojure. In this one, I'd like to share my thoughts on the advantages of using it for cross-platform mobile development. Dart programmers are the target audience, but anyone interested in Flutter and/or Clojure is welcome.

A short history of Clojure

Clojure was not created in a hurry (JS), it didn't try to seize the market with a multimillion budget (Java). It wasn't backed by a powerful company (Go, Dart,

// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1