Skip to content

Instantly share code, notes, and snippets.

@naholyr
naholyr / _sample1.coffee
Last active December 13, 2015 23:09
ETL DSL based on CoffeeScript (arrows ftw)
# First way: Declare the components and branch them on the go
csv
file: "random-numbers.csv"
-> transform
clone: true
mapping:
sum: (row) -> row.rnd + row.count
diff: (row) -> row.rnd - row.count
@naholyr
naholyr / test.hs
Last active December 13, 2015 18:59
Why Integer instead of Num?
-- in GHCI
> let sum' = (foldl (\total value -> total + value) 0)
> :t sum'
sum' :: [Integer] -> Integer -- I would have expected something more generic like Num a => [a] -> a
> :t (+)
(+) :: Num a => a -> a -> a
> :t 0
0 :: Num a => a
@naholyr
naholyr / AndroidManifest.xml
Created February 13, 2013 15:11
Sample webview to encapsulate webapp
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="union.pocweb" android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<activity android:name=".MainActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
// 1. Function generator
function adder (n) {
return function (x) {
return x + n;
};
}
var add1 = adder(1);
@naholyr
naholyr / 0.github-backed-comments.md
Last active August 25, 2022 17:44
Git(Hub)-backed comments system

General context

  • A static website using a generator (like Jekyll)
  • Comments are in a folder, one comment = one JSON file (attached to article based on path + filename)
  • website is versionned using git, repository hosted by github (cool for pull-requests)

Posting a new comment

OK here we need some dynamism ;)

@naholyr
naholyr / readme.md
Last active December 10, 2015 23:39
Comment je devrais tweeter

La situation actuelle

  • @naholyr est mon compte historique, lié à mon pseudo, mêlant perso et techno. Ça s'est simplement fait naturellement au fur et à mesure de l'utilisation :)
  • @nchambrier est un compte que j'ai créé pour… je sais pas trop quoi encore, aidez-moi donc à choisir :)

L'objectif

Dissocier le "perso" du "technique" voire du "pro".

Les options

@naholyr
naholyr / monkey-patch.js
Created December 21, 2012 11:52
JS monkey patching
// Original method
var object = {
method: function (x, y) {
return x+y;
}
}
// Add operations before or after!
object.method = (function (original) {
return function (x, y) {
@naholyr
naholyr / _service.md
Created December 13, 2012 09:39
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@naholyr
naholyr / robot.js
Created December 3, 2012 21:16
naholyr
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.rotateCannon(10);
@naholyr
naholyr / git-pr.md
Created November 22, 2012 18:11
Using "hub" to automatically push & PR

git-pr

Part of my personal shortcuts for the usual pull-request-based workflow.

Setup

Given you have an "upstream" repository you need to work on:

  1. Fork it
  2. Clone your fork locally (repo "origin")