Skip to content

Instantly share code, notes, and snippets.

Avatar

Anders Dahnielson dahnielson

View GitHub Profile
@dahnielson
dahnielson / OpenFileButton.svelte
Last active Aug 2, 2020
Open the file dialog in Svelte
View OpenFileButton.svelte
<script>
let fileInput
</script>
<style>
input {
display: none;
}
</style>
@dahnielson
dahnielson / lcd.c
Last active Jul 2, 2018
I can't work out why this doesn't work properly...
View lcd.c
#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
Module that works directly in browser and node.js
View index.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 Mar 14, 2017
Sitemap for webscraper.io and Python script
View delicious.json
{
"startUrl": "https://del.icio.us/<your username>?&page=[1-100]",
"selectors": [{
"parentSelectors": ["_root"],
"type": "SelectorElement",
"multiple": true,
"id": "bookmark",
"selector": "div.articleThumbBlockOuter",
"delay": ""
}, {
View DualPaneFlickable.qml
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 Feb 23, 2014
Style for Qt Creator inspired by SublimeText 2
View monokai.xml
<?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 Jan 3, 2012
(Re)map caps lock key to escape
View .Xmodmap
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
View gist:512192
<?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 <scripts@afrosoft.co.cc>
*/
function generate_salt($max = 40)
@dahnielson
dahnielson / combinations.php
Created Aug 4, 2010
Get letter combinations
View combinations.php
<?php
function filterSign($var)
{
return strlen($var) < 2 ? false : true;
}
function getCombinations($values)
{
$perms = array(null);
@dahnielson
dahnielson / UUID.php
Last active Jun 4, 2021
Pure PHP UUID generator
View UUID.php
<?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.