Skip to content

Instantly share code, notes, and snippets.

View lepinsk's full-sized avatar
😶‍🌫️

Julian Lepinski lepinsk

😶‍🌫️
View GitHub Profile
@oznu
oznu / index.js
Last active January 12, 2024 13:11
Homebridge Switch Plugin Example
'use strict'
let Service, Characteristic
module.exports = (homebridge) => {
/* this is the starting point for the plugin where we register the accessory */
Service = homebridge.hap.Service
Characteristic = homebridge.hap.Characteristic
homebridge.registerAccessory('homebridge-switch-example', 'SwitchExample', SwitchAccessory)
}
@need12648430
need12648430 / example.js
Last active August 29, 2015 14:25
tiny mustache-like templating engine in 2.6kb/108 loc
var template = "{?condition}Condition exists! {condition}{/condition}\n\n" +
"{^whereami}I am not here!{/whereami}\n\n" +
"{#list}{name} is {age} years old! {?old}They are *old*!{/old}{!old}They are not old!{/old}\n{/list}";
console.log(stache(template, {
condition: "Hello world!",
list: [
{name: "Charles", age: "25"},
{name: "Bob", age: "42", old: true},
{name: "Samantha", age: "32"},
@Chase-san
Chase-san / index.php
Last active December 12, 2015 02:18
A very tiny image gallery.
<?php /* Copyright(c) 2013 Robert Maupin. Released under the ZLIB License. */
if(count($_FILES) > 0) {
extract($_FILES['file']);
list($w,$h,$type)=getimagesize($tmp_name);
/*see exif-imagetype() documentation :) */
if(!$type||$type>3||filesize($tmp_name)>1024*200)
exit();
$ext=image_type_to_extension($type,false);
$md5=md5_file($tmp_name);
move_uploaded_file($tmp_name,$n="img/$md5.$ext");