Skip to content

Instantly share code, notes, and snippets.

View MightyPork's full-sized avatar
🐶
meow

Ondřej Hruška MightyPork

🐶
meow
View GitHub Profile
@MightyPork
MightyPork / twitter_bg_fix_v2.js
Created July 23, 2015 17:41
Userscript to fix twitter's background
// ==UserScript==
// @name Twitter Background Fixer
// @namespace http://your.homepage/
// @version 0.1
// @description Adds your custom color and image back to twitter's background.
// @author MightyPork
// @match https://twitter.com/
// @grant none
// ==/UserScript==
@MightyPork
MightyPork / Object.php
Created July 30, 2015 12:50
Generic PHP object class
<?php
/**
* Dynamic dictionary object
*
* - works as object and array
* - countable
* - iterable with foreach
* - can be created from JSON, array or stdClass object
@MightyPork
MightyPork / TieredLock.js
Created August 11, 2015 20:48
TieredLock JS class
/**
* Tiered lock works as a multi-level boolean / mutex.
*
* Main use case is to disable page refresh during
* an ongoing task, when there can be multiple such tasks.
*/
function TieredLock() {
this._weight = 0;
this._locks = {};
}
@MightyPork
MightyPork / elements_json.php
Last active January 3, 2024 14:43
Generate JSON of PT elements
<?php
$table = [
["Hydrogen", "H", "1", "1.00794", "0.0708 (@ -253°C)", "14.01", "20.28", "79", "32", "154 (-1e)", "14.1", "14.267 (H-H)", "0.117 (H-H)", "0.904 (H-H)", "0.1815", "110.00", "2.20", "1311.3", "1, -1", "1s<sup>1</sup>", "HEX", "3.750", "1.731", "Colorless, odorless, tasteless gas", "1766 (England)", "Henry Cavendish", "Greek: hydro (water) and genes (generate)", 1, 1, 0x7FFFFFFF, 0xAAAA, 0xFFFF, 0xAAAA],
["Helium", "He", "2", "4.002602", "0.147 (@ -270°C)", "0.95", "4.216", "0.0", "n/a", "93", "31.8", "5.188", "n/a", "0.08", "0.152", "n/a", "n/a", "2361.3", "n/a", "1s<sup>2</sup>", "HEX", "3.570", "1.633", "Inert, colorless, odorless, tasteless gas", "1895 (Scotland/Sweden)", "Sir William Ramsey, Nils Langet, P.T.Cleve", "Greek: helios (sun).", 18, 1, 0x7FFFFFFF, 0xC000, 0x7000, 0x0],
["Lithium", "Li", "3", "6.941", "0.534", "553.69", "1118.15", "155", "163", "68 (+1e)", "13.1", "3.489", "2.89", "148", "84.8", "400.00", "0.98", "519.9", "1", "[He] 2s<sup>1</sup>", "BCC", "3.490", "n/a", "So
source .bash_colors
export PROMPT_DIRTRIM=2
function _branch_ps1 {
_branch=""
if [ -d .git ]; then
_br=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
if [ $_br == "master" ]; then
#!/bin/bash
# Reset
Reset='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
@MightyPork
MightyPork / leftTrimBlock.php
Created September 18, 2015 14:10
leftTrimBlock() function
<?php
/**
* Remove left padding space from all lines,
* while preserving indentation.
*
* @param string $txt
* @returns string trimmed block of text
*/
function leftTrimBlock($txt)
module.exports = function(grunt) {
grunt.file.defaultEncoding = 'utf8';
grunt.file.preserveBOM = false;
grunt.initConfig({
copy: {
fonts: {
@MightyPork
MightyPork / groupBy.php
Last active February 25, 2018 21:16
grouping function
<?php
/**
* Group an array using a callback or each element's property/index
*
* @param array $arr array to group
* @param callable|string $grouper hashing function, or property/index of each item to group by
* @return array grouped
*/
function groupBy(array $arr, $grouper)
<?php
$origname = 'GPIOB_IDR';
$basename = 'BB_'.$origname;
echo "_$basename EQU PERIPH_BB_BASE + ($origname - PERIPH_BASE) * 32\n\n";
for($i=0; $i<16; $i++) {
echo "{$basename}_$i EQU _{$basename} + (4 * $i)\n";