Skip to content

Instantly share code, notes, and snippets.

View dgellow's full-sized avatar
🐢
Pulu pulu 🏳️‍🌈

Sam El-Borai dgellow

🐢
Pulu pulu 🏳️‍🌈
View GitHub Profile
import strutils as str
import math except sin
# Helpers
proc newline(text: string): string =
text & "\r\n"
proc colorize(text: string, color: int, isBright: bool): string =
let
from os import path
import re
import pdb
import sys
filename = path.join(
path.dirname(__file__), 'semaine_depenses.txt'
)
with open(filename, 'r') as file:
// Load the default exported object from some modules
import React from 'react';
import Actions from './Actions.jsx';
import ProgressBar from './ProgressBar.jsx';
// Load all fns exported in a module
import * as api from './api';
// Load some fns exported in a module
import {decodeParams, pad} from './utils';

Some fake data

@dgellow
dgellow / thread-last.wisp
Created April 4, 2015 19:32
clojure's thread-last macro, aka ->>, in wisp | See https://clojuredocs.org/clojure.core/-%3E%3E
(defmacro -->
[x & forms]
(let [next (fn [x] (let [r (rest x)] (if (empty? r) nil r)))]
(loop [x x, forms forms]
(if forms
(let [form (first forms)
threaded (if (list? form)
(with-meta
`(~(first form) ~@(next form) ~x)
(meta form))
@dgellow
dgellow / server.js
Last active August 29, 2015 14:17
Wisp vs Javascript comparison
if (Meteor.isServer) {
Meteor.publish('documents', function() {
return Documents.find({});
});
Meteor.startup(function() {
var doc = Documents.findOne({title: 'Initial document'});
if (!doc) {
Documents.insert({
title 'Initial document',
@dgellow
dgellow / _README.md
Last active September 15, 2016 08:49
Simple multi user text editor based on Meteor http://react-sync-texteditor.meteor.com/

Install Meteor

Follow instructions.

Prepare the project

# Create a new meteor project
meteor create <appName>
cd <appName>

# Delete default files
@dgellow
dgellow / mmm-jsx.el
Last active August 29, 2015 14:15
Configure mmm-mode for React, using js2-mode for javascript and web-mode for JSX.
(require 'mmm-mode)
(mmm-add-classes
'((jsx
:submode web-mode
:front "\\((\\)[[:space:]\n]*<"
:front-match 1
:back ">[[:space:]\n]*\\()\\)"
:back-match 1)))
@dgellow
dgellow / browserify.js
Created September 19, 2014 12:02
A browserify task, currently the factor plugin does not write expected files.
var watchify = require('watchify');
var browserify = require('browserify');
var factor = require('factor-bundle');
var bundleLogger = require('../util/bundleLogger');
var handleErrors = require('../util/handleErrors');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
gulp.task('browserify', function() {
@dgellow
dgellow / part-cons.rkt
Last active August 29, 2015 14:01
A function to transform a list into a list of cons.
;; Example:
;; (part-cons '(1 2 3 4 5)) ;; => '((1 . 2) (3 . 4) (5))
(define (part-cons l [acc '()])
(if (equal? l null)
acc
(let ([k (car l)]
[v (if (null? (cdr l)) null (cadr l))]
[ll (if (> (length l) 1)
(drop l 2)