Skip to content

Instantly share code, notes, and snippets.

View kelunik's full-sized avatar

Niklas Keller kelunik

View GitHub Profile
@kelunik
kelunik / setup.sh
Last active March 10, 2016 11:32
X1C Install
#!/bin/bash
# re-run as root if necessary
if [[ $EUID -ne 0 ]]; then
sudo ./$0
exit
fi
# apt-get install -y acpi
@DaveRandom
DaveRandom / .gitignore
Created August 2, 2016 10:07
Default repository layout - PHP web application
vendor # ignore composer data
# ignore PHP Storm config
# you may want to ignore your IDE config and you may want to commit it, up to you
.idea
@zeekay
zeekay / say-hi.py
Last active May 19, 2017 20:58
IRC chat client in < 60 lines of code.
#!/usr/bin/env python
#
# Minimal IRC client. Compatible with Python 2 and 3.
import os, select, signal, socket, sys, time
try: username = os.getlogin()
except: username = "unknown"
hostname = socket.gethostname()
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@BenMorel
BenMorel / .travis.install-mysql-5.7.sh
Last active December 6, 2019 06:24
Install MySQL 5.7 on Travis-CI
sudo apt-get remove --purge "^mysql.*"
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/log/mysql
echo mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7-dmr | sudo debconf-set-selections
wget http://dev.mysql.com/get/mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo dpkg --install mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo apt-get update -q
sudo apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" mysql-server
@neilellis
neilellis / README.md
Last active May 26, 2020 13:09
Build large maven projects quicker on OS X, this gist will ensure a ramdisk is mounted in /Volumes/ramdisk and triggers a profile that redirects output to a ram disk. It also only builds modules which have changed and their dependent modules. This is done by supplying the target directory of the ultimate artifact you are interested in.

Make sure you have a profile called quick that redefines the location of maven's output to the ramdisk. To do this ensure all of the below are in your parent POM.

<properties><my.build.directory>target</my.build.directory></properties>

<build><directory>${my.build.directory}</directory></build

<profile>
  <id>quick</id>
@silkentrance
silkentrance / MyComponent.ts
Last active March 10, 2021 13:09
vue-router typescript integration fails
import Vue from 'vue';
import Component from 'vue-class-component';
@Component({
name : 'component'
})
export default class MyComponent extends Vue {
beforeCreate() {
@codesnik
codesnik / empty-maxmind-db-writer.pl
Created December 27, 2015 02:48
it creates 'empty.mmdb', empty MaxMind geoip database, good enough for your tests
#!/usr/local/bin/perl
# run 'mcpan MaxMind::DB::Writer' beforehand
use MaxMind::DB::Writer::Tree;
use Net::Works::Network;
my %types = (
#color => 'utf8_string',
#dogs => [ 'array', 'utf8_string' ],
#size => 'uint16',
@theseer
theseer / confused.md
Created March 24, 2019 16:36
What happend to the `If-Modified-Since` header?

If-Modified-Since, PHP CLI Server and Firefox

Explanation

When sending the cache control header Cache-Control: no-cache, must-revalidate along with a Last-Modified timestamp, the browser is required to send along an If-Modified-Since header for the next request to the same URL.

The server then is entitled to return HTTP/1.1 304 Not modified in case the content didn't change and the stored copy may still be used.

Sample Code

@prurigro
prurigro / archroot.sh
Last active June 17, 2021 22:31
An overlayfs-based chroot management script for deployable arch build environments
#!/usr/bin/env bash
#
# archroot
# An overlayfs chroot management script for deployable arch build environments
#
# Version 1.18
#
# Written by Kevin MacMartin
# Released under the MIT license
@bwoebi
bwoebi / text.md
Last active February 19, 2022 01:08
fread() on non-blocking sockets

Reading of non-blocking TCP sockets in PHP

As a short heads-up for those unfamiliar:

  • There is a PHP level buffer. Whenever more is actually read from the socket (default chunk size is 8192), than the user requests in his PHP code, the data is stored there.
  • There is an OS level buffer. There all incoming network data lands. The event loop only knows of that one and checks that one for being non-empty.

Trivial single read

The trivial reading function in PHP is fread($socket, $maxSize).