Skip to content

Instantly share code, notes, and snippets.

View dahnielson's full-sized avatar

Anders Dahnielson dahnielson

View GitHub Profile
@dahnielson
dahnielson / dirate.py
Created July 7, 2010 09:12
Transfer rate/storage capacity calculator
# Load in IPython and use as transfer rate
# and storage capacity calculator.
bytes = 8
bits = 24
width = 1280
height = 720
fps = 24
@dahnielson
dahnielson / gist:469501
Created July 9, 2010 14:15
Time accumulator
import pygame
class Time(object):
def __init__(self, uiTimeStep):
"Takes the time step in milliseconds as argument."
self.uiTimeStep = uiTimeStep
self.uiNewTime = 0
self.uiCurrentTime = 0
self.uiTimeAccumulator = 0
@dahnielson
dahnielson / exceptions.md
Created July 29, 2010 11:55
Standard exceptions

Exceptions

  • std::exception
    • std::bad_alloc thrown by new on allocation failure.
    • std::bad_cast thrown by dynamic_cast when fails with a referenced type.
    • std::bad_exception thrown when an exception type doesn't match any catch.
    • std::bad_typeid thrown by typeid.
    • std::logic_error thrown by logic errors, represent problems in the internal logic of a program; in theory, these are preventable, and even detectable
@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.
@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 / 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 / .Xmodmap
Created January 3, 2012 13:18
(Re)map caps lock key to escape
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
@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"/>
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 / 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": ""
}, {