Skip to content

Instantly share code, notes, and snippets.

View lionello's full-sized avatar
🇭🇰

Lio李歐 lionello

🇭🇰
View GitHub Profile
@lionello
lionello / wol.c
Created September 8, 2013 02:48
Wake-On-LAN
// Portable Wake-On-Lan by Lionello Lunesu, placed in the public domain
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#ifdef _MSC_VER
#pragma comment(lib, "ws2_32.lib")
#endif
#else
#include <sys/socket.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <SparkFunHTU21D.h>
#include<stdlib.h>
#include "DHT.h"
#define SSID "XinCheJian"//your network name
@paperdigits
paperdigits / default.nix
Created January 10, 2017 06:15
nix-shell environment for middleman
# nix-shell -p bundler bundix
# bundler lock && bundler package --path vendor/cache --no-install && bundix && exit
# nix-shell
with (import <nixpkgs> {});
let
env = bundlerEnv {
name = "test-package";
inherit ruby;
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
@adisbladis
adisbladis / .direnvrc
Created June 6, 2018 09:44
direnvrc nix cache
use_nix() {
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix)
local cache_key=$(nix-instantiate "$shell_file" 2> /dev/null | shasum -a 1 | cut -d ' ' -f 1)
# Use ram as virtualenv storage
local tmpdir
case $(uname -s) in
Linux*) tmpdir=$XDG_RUNTIME_DIR;;
Darwin*) tmpdir_SDK=$TMPDIR;;
*) tmpdir=/tmp
@sveitser
sveitser / Entropy.ipynb
Last active September 7, 2018 08:00
Was wondering about entropy of pass phrases.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lionello
lionello / .direnvrc
Last active August 6, 2019 08:37 — forked from adisbladis/.direnvrc
Direnv nix cache. Put this file in your HOME folder.
#!/bin/bash
#
# Cache nix-shell environment
#
# - watches shell.nix (or default.nix), ~/.direnvrc and .envrc
# - based on https://github.com/direnv/direnv/wiki/Nix
#
use_nix() {
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix)
if [[ ! -f "$shell_file" ]]; then return; fi
{ pkgs ? import <nixpkgs> {} }:
let
inherit (pkgs) lib stdenv ruby_2_3 rake bundler bundlerEnv openssl defaultGemConfig;
rubyEnv = bundlerEnv {
name = "mezzo";
ruby = ruby_2_3;
gemdir = ./.;
@woutgg
woutgg / dhcp
Created March 6, 2014 21:09
openwrt ap+sta configuration
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
@neilco
neilco / RSASHA1.swift
Created April 27, 2015 09:07
RSA-SHA1 signing with a PKCS#12 private key
//
// RSASHA1.swift
//
// Copyright (c) 2015 Neil Cowburn. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@ArthurYidi
ArthurYidi / translatekeycodes.swift
Created April 6, 2016 02:57
virtual key codes to unicode characters
func keyCodeToString(keyCode: CGKeyCode) -> String {
let curKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()
let ptr = TISGetInputSourceProperty(curKeyboard, kTISPropertyUnicodeKeyLayoutData)
let keyboardLayoutPtr = UnsafePointer<UCKeyboardLayout>(ptr)
var deadKeyState: UInt32 = 0
var actualStringLength = 0
var unicodeString = [UniChar](count: 255, repeatedValue: 0)
let status = UCKeyTranslate(keyboardLayoutPtr,