Skip to content

Instantly share code, notes, and snippets.

View chrisnew's full-sized avatar
👾
wat

Christian R. chrisnew

👾
wat
  • InterWebs Ltd.
  • Sofia
View GitHub Profile
@brandonheyer
brandonheyer / rgbToHSL.php
Last active June 12, 2021 06:49
PHP snippet to convert RGB to HSL and HSL to RGB.
<?
function rgbToHsl( $r, $g, $b ) {
$oldR = $r;
$oldG = $g;
$oldB = $b;
$r /= 255;
$g /= 255;
$b /= 255;
@chrisnew
chrisnew / hd44780-lcd.js
Last active August 12, 2016 13:23
HD44780 LCD on a Raspberry Pi controlled by node.js with onoff and sleep.
var Gpio = require('onoff').Gpio;
var sleep = require('sleep');
var displayPorts = {
RS: 7,
E: 8,
D4: 25,
D5: 24,
D6: 23,
D7: 18,
@plentz
plentz / nginx.conf
Last active July 25, 2024 09:38
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@aholmes
aholmes / Traverse.php
Last active January 2, 2016 14:49
The OOP version of https://igor.io/2014/01/08/functional-library-traversal.html for ghits and shiggles.
<?php
class Traverse implements ArrayAccess {
protected $container;
function __construct($array) {
$this->container = $array;
}
public function offsetExists($offset) {
return isset($this->container[$offset]);
}
@CodesInChaos
CodesInChaos / gist:8374632
Created January 11, 2014 18:20
Ed25519 amd64 bug

While visiting 30c3, I attended the You-broke-the-Internet workshop on NaCl.

One thing mentioned in the talk was that auditing crypto code is a lot of work, and that this is one of the reasons why Ed25519 isn't included in NaCl yet (they promised a version including it for 2014). The speakers mentioned a bug in the amd64 assembly implementation of Ed25519 as an example of a bug that can only be found by auditing, not by randomized tests. This bug is caused by a carry being added in the wrong place, but since that carry is usually zero, the bug is hard to fint (occurs with probability 2^{-60} or so).

The TweetNaCl paper briefly mentions this bug as well:

Partial audits have revealed a bug in this software (r1 += 0 + carry should be r2 += 0 + carry in amd64-64-24k) that would not be caught by random tests; this illustrates the importance of audits.

#!/bin/bash
#
# Copyright (c) 2015, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
@mnshankar
mnshankar / post-receive.sh
Last active July 24, 2016 22:20
post-receive hook for git deploy (Laravel 4)
#!/bin/sh
WEBROOT=/var/www/domain.com/project
GIT_WORK_TREE=$WEBROOT git checkout -f
#change directory to the project dir
cd $WEBROOT
rm -f storage/cache/*
echo 'cache cleared'
rm -f storage/views/*
echo 'views cleared'
# Check if a composer.json file is present
@mlynch
mlynch / autofocus.js
Last active August 24, 2022 15:03
AngularJS Autofocus directive
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus>
*
* License: MIT
*/
@pawelkl-zz
pawelkl-zz / config
Last active August 17, 2023 18:32
my i3 config
# http://i3wm.org/docs/userguide.html
# font pango: share tech mono, comfortaa, FontAwesome, octicons, Ionicons 10
# Lekton, NotCourierSans, SaxMono
font pango: Ubuntu Mono for Powerline, KlarTextMono, comfortaa, FontAwesome, octicons, Ionicons 11
# ubuntu 10
# ubuntu mono 11
smart_borders on
# on / no_gaps
# gaps inner 5
@ryancdotorg
ryancdotorg / rsabd.py
Last active March 13, 2023 15:57
backdoored rsa key generation
#!/usr/bin/env python
import sys
import gmpy
import curve25519
from struct import pack
from hashlib import sha256
from binascii import hexlify, unhexlify