Skip to content

Instantly share code, notes, and snippets.

View akabab's full-sized avatar
🧗
On the rock

Yoann Cribier akabab

🧗
On the rock
View GitHub Profile
const min = (a, b) => {
if (a < b) {
return a
}
else {
return b
}
}
const min = (a, b) => a < b ? a : b
// ES5
function sum (a, b) {
return a + b
}
// which is similar to
var sum = function (a, b) {
return a + b
}
// 2d Arrays
const Array2d = (w, h = w, fillWith = undefined) =>
Array(h).fill(fillWith).map(e => e = Array(w).fill(fillWith))
// 2D array fill of 0
Array(10).fill(0).map(e => e = Array(10).fill(0))
// ->
Array2d(10, 10, 0)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
======================================================================
Volt
======================================================================
A Sublime Text 3 / Textmate theme.
Copyright (c) 2017 akabab.
Released under the MIT License <http://opensource.org/licenses/MIT>
======================================================================
@akabab
akabab / read_fd.c
Created August 26, 2017 17:37
Read on a file descriptor (parameter nbytes)
/*
idea was to resolve unexpected short-reads (when reading on stdin or pipe), read was returning less bytes than asked
cf. https://stackoverflow.com/a/8975581/5183171
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *read_fd(int fd, int nbyte)
@akabab
akabab / Iconizer.sh
Last active November 24, 2016 16:12 — forked from richellis/Iconizer.sh
Create iOS application icons from one PDF file. Requires ImageMagick.
#!/bin/sh
#
# Iconizer shell script by Steve Richey (srichey@floatlearning.com)
# Modified by Rich Ellis (rich@richellis.net) based on contributions on Github from crishoj, giria
# https://gist.github.com/steverichey/8493f3bd31ae71a9c933/forks
#
# This is a simple tool to generate all necessary app icon sizes and the JSON file for an *EXISTING* Xcode project from one file.
# To use: specify the path to your vector graphic (PDF format) and the path to your Xcode folder containing Assets.xcassets
# Example: sh iconizer.sh MyVectorGraphic.pdf MyXcodeProject
/*
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.
Examples include "amor roma", "step on no pets", "kayak", "abcdcba"
Next implementations are strict with capital letters, accents, punctuation, and word dividers.
*/
// 1st shot
// expensive for memory: although Array.reverse() is lazy and does not create new storage (according to documentation - Swift 2.1),
// passing it into String initializer creates an entire new copy of the source string with reversed characters
@akabab
akabab / FAQ42
Last active March 16, 2016 07:50
Q: j’ai un permission denied sur un brew install, any clue ?
A: mkdir -p ~/Library/Caches/Homebrew && export HOMEBREW_CACHE=$_
+: export PATH=$HOME/.brew/bin:$PATH (add to '.zshrc')
+: rm -rf .brew && /usr/local/bin/brew update
l: https://github.com/Homebrew/homebrew/issues/41822
Q: reset une session ?
A: sinon y’a un bouton “Reset home directory” au niveau des tools de synchro, so simple ..
Q: quelqu’un saurait comment modifier le PIN d’entrée à l’école ?