Skip to content

Instantly share code, notes, and snippets.

View kenOfYugen's full-sized avatar

Kyriakos-Ioannis D. Kyriakou kenOfYugen

View GitHub Profile
@kenOfYugen
kenOfYugen / minimal.css
Created June 22, 2019 23:52
look great nearly everywhere
main {
max-width: 70ch;
padding: 2ch;
margin: auto;
}
#![feature(conservative_impl_trait)]
use std::{io, fs, ffi};
#[derive(Debug)]
enum ReadDirErrors {
IOError(io::Error),
OSString(ffi::OsString),
}
@kenOfYugen
kenOfYugen / package.json
Created October 11, 2016 10:21
sample package.json
{
"name": "project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"scripts": {
"lint": "coffeelint src/",
@kenOfYugen
kenOfYugen / .nanorc
Created October 7, 2016 10:08
Current nano configuration
include /usr/share/nano/*.nanorc
set smooth
set autoindent
set morespace
set nohelp
set tabsize 2
set tabstospaces
set mouse
set fill 80
@kenOfYugen
kenOfYugen / Preferences.sublime-settings
Last active June 1, 2017 19:14
Sublime 3 Settings
{
"args":
{
"show_sidebar": true
},
"bold_folder_labels": false,
"caption": "AutoSideBar: Toggle",
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"command": "auto_side_bar_toggle",
@kenOfYugen
kenOfYugen / gist:969cee48e1bf10fac5cf605c21b2fa7d
Created August 13, 2016 13:15 — forked from shesek/gist:3929926
Higher order functions for nodejs-style callbacks error handling

I've used promises for quite some time, but ended up going back to nodejs-style callbacks and creating a bunch of higher-order functions that makes handling that easier and reduce the boilerplate code. The two most useful ones, that really made it much easier, deal with error handling/bubbling: (CoffeeScript)

iferr = (errfn, succfn) -> (e, a...) -> if e? then errfn e else succfn a...
throwerr = iferr.bind null, (e) -> throw e


# To let an error bubble up, `iferr` decorates the success function and the error function, and decide which one should handle the response
# This replaces `if (err) return fn err` that you see all over the place
@kenOfYugen
kenOfYugen / stringCp.c
Created March 16, 2016 18:24
String Copying in C
#include "stdio.h"
int lengthOf(char input[]) {
int i;
for (i = 0; input[i] != '\0'; i++);
return i;
}
void copyString(char input[], char output[]) {
int i;
@kenOfYugen
kenOfYugen / fnPtr.c
Last active March 16, 2016 18:24
Pointer Function examples in C
#include <stdio.h>
int add(int x, int y) {
return x + y;
}
int substract(int x, int y) {
return x - y;
}