Skip to content

Instantly share code, notes, and snippets.

@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 / _README.md
Last active December 5, 2023 23:37
Chrome extension exposing JS API

Install

Clone the repo and drop the folder into "chrome://extensions" page.

Use

Open any web page ("about:blank" will work too) and a console, then inspect and play with MY_API global variable.

@naholyr
naholyr / BOOKLET.md
Last active September 19, 2023 11:45
How to print a booklet, the copy-pasta tables

Printing a booklet

Printing instructions:

  • Duplex
    • short edge for A5 booklet
    • long edge for A6 booklet
  • X pages per side, so if you're printing on A4 sheets:
    • 2 pages per side for A5 booklet (~21×15 mm)
  • 4 pages per side for A6 booklet (~10×15 mm)
@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 / git-ignored.sh
Created February 15, 2012 15:41
List all ignored files
# I didn't look, but I'm even pretty sure there is a dedicated command for this with Git.
# and this is just a piece of cake, 5 minutes max to implement this...
# Edit - actually, you can simply call this:
# git ls-files --others --ignored --exclude-standard
find -name .gitignore | while read f
do
d="$(dirname "$f")"
cat $f | while read p
@naholyr
naholyr / decode_live.free.fr.sh
Created January 5, 2012 09:55
Decode MD5 from live.free.fr
#!/bin/bash
# <troll>If you don't have bash, go get a real OS.</troll>
curl -s "http://md5.noisette.ch/md5.php?hash=$(curl -s http://live.free.fr | gunzip | tail -n 36 | head -n 32 | grep '[a-f0-9]' -o | xargs echo -n | sed 's/ //g')" | grep '<string>' | sed 's/^.*\[CDATA\[\(.*\)\]\].*$/\1/'
@naholyr
naholyr / socket.io.js
Created June 14, 2012 13:40
socket.io.js
/*! Socket.IO.js build:0.9.6, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
(function (exports, global) {
const category = useSelector(state => state.app.currentCategory);
const asyncFunction = React.useCallback(
category ? () => getProducts(category) : null,
[category]
);
const [error, loading, products] = useAsync(asyncFunction, category);
@naholyr
naholyr / test.jsx
Last active October 16, 2021 11:08
import React, { Fragment, Component } from 'react';
import ReactDOM from 'react-dom';
class ContextData {
watchers = []
constructor(initialState = {}) {
this.state = initialState
@naholyr
naholyr / compare.php
Created February 22, 2012 16:27
Extract namespace from a PHP file
<?php
// Works in every situations
function by_token ($src) {
$tokens = token_get_all($src);
$count = count($tokens);
$i = 0;
$namespace = '';
$namespace_ok = false;
while ($i < $count) {