Skip to content

Instantly share code, notes, and snippets.

View dahnielson's full-sized avatar

Anders Dahnielson dahnielson

View GitHub Profile
@dahnielson
dahnielson / OpenFileButton.svelte
Last active August 2, 2020 08:49
Open the file dialog in Svelte
<script>
let fileInput
</script>
<style>
input {
display: none;
}
</style>
@dahnielson
dahnielson / lcd.c
Last active July 2, 2018 09:48
I can't work out why this doesn't work properly...
#include "lcd.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
@dahnielson
dahnielson / index.js
Last active May 26, 2018 20:43
Module that works directly in browser and node.js
// Check whether we are in browser or node.js
var _self = (typeof window !== 'undefined') ? window : {};
// Scoping with anonymous closure for browser
var Foo = (function(){
var _ = _self.Foo = {
init: function() {
}
}
@dahnielson
dahnielson / delicious.json
Last active March 14, 2017 19:34
Sitemap for webscraper.io and Python script
{
"startUrl": "https://del.icio.us/<your username>?&page=[1-100]",
"selectors": [{
"parentSelectors": ["_root"],
"type": "SelectorElement",
"multiple": true,
"id": "bookmark",
"selector": "div.articleThumbBlockOuter",
"delay": ""
}, {
import QtQuick 2.2
Flickable {
id: flickable
anchors.fill: parent
contentWidth: flickable.width * 2
contentHeight: 0
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.HorizontalFlick
onMovementEnded: snapPage(this)
@dahnielson
dahnielson / monokai.xml
Created February 23, 2014 23:30
Style for Qt Creator inspired by SublimeText 2
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme version="1.0" name="Monokai">
<style name="Text" foreground="#f8f8f2" background="#272822"/>
<style name="Link" foreground="#0055ff"/>
<style name="Selection" foreground="#f8f8f2" background="#49483e"/>
<style name="LineNumber" foreground="#888888" background="#232323"/>
<style name="SearchResult" foreground="#000000" background="#ffe792"/>
<style name="SearchScope" background="#222200"/>
<style name="Parentheses" foreground="#ff5555" background="#333333"/>
<style name="CurrentLine"/>
@dahnielson
dahnielson / .Xmodmap
Created January 3, 2012 13:18
(Re)map caps lock key to escape
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
@dahnielson
dahnielson / gist:512192
Created August 6, 2010 23:24
Generate salt
<?php
/**
* This function generates a password salt as a string of x characters
* ranging from a-zA-Z0-9.
*
* @param $max integer The number of characters in the string
* @author AfroSoft <[email protected]>
*/
function generate_salt($max = 40)
@dahnielson
dahnielson / combinations.php
Created August 4, 2010 22:10
Get letter combinations
<?php
function filterSign($var)
{
return strlen($var) < 2 ? false : true;
}
function getCombinations($values)
{
$perms = array(null);
@dahnielson
dahnielson / UUID.php
Last active September 1, 2024 11:34
Pure PHP UUID generator
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.