Skip to content

Instantly share code, notes, and snippets.

View Deledrius's full-sized avatar

Joseph Davies Deledrius

View GitHub Profile
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@jpoehls
jpoehls / gist:2030795
Created March 13, 2012 19:02
Using CTRL+W to close tabs in Visual Studio

In Tools | Options | Keyboard...

  1. Add CTRL+W as a Global shortcut for Window.CloseDocumentWindow
  2. Remove the CTRL+W shortcut for Edit.SelectCurrentWord

The caveat to this is if you are used to using CTRL+W to select the current word. If you do, find another shortcut that works for that.

@tony-landis
tony-landis / recurse_image_optimize.sh
Created October 18, 2012 01:36
Recursively Optimize JPGs and PNGs using PNGCRUSH and JPEGTRAN
#!/bin/sh
# script for optimizing images in a directory (recursive)
# pngcrush & jpegtran settings from:
# http://developer.yahoo.com/performance/rules.html#opt_images
# pngcrush
for png in `find . | grep .png`; do
echo "crushing $png ..."
pngcrush -rem alla -reduce -brute "$png" temp.png
@preshing
preshing / build_cross_gcc
Last active June 24, 2024 09:46
A shell script to download packages for, configure, build and install a GCC cross-compiler.
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# This script will download packages for, configure, build and install a GCC cross-compiler.
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running.
# If you get an error and need to resume the script from some point in the middle,
# just delete/comment the preceding lines before running it again.
@fbender
fbender / sleep-timer.scpt
Last active March 5, 2024 09:51
AppleScript to put your Mac to sleep after X minutes, fading out the system volume shortly before sleeping. Can be turned into an app via the "Export" feature of the AppleScript Editor.
-- written by Florian Bender, 2015
-- based on work by Michael Wyszomierski <https://wysz.com/wyszdom/2009/06/simple-sleep-timer-with-applescript/>
-- license: Public Domain / CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
tell application "System Events"
set volumeSettings to get volume settings
set volumeValue to (output volume of volumeSettings)
set fadeTime to 10 -- time in seconds for fade change
set fadeChange to (volumeValue div fadeTime)
-- display alert "Volume: " & volumeValue & ", Delta: " & fadeChange
display dialog "Sleep time (min):" default answer "25"
@0XDE57
0XDE57 / config.md
Last active July 7, 2024 00:25
Firefox about:config privacy settings

ABOUT

about:config settings to harden the Firefox browser. Privacy and performance enhancements.
To change these settings type 'about:config' in the url bar. Then search the setting you would like to change and modify the value. Some settings may break certain websites from functioning and rendering normally. Some settings may also make firefox unstable. I am not liable for any damages/loss of data.

Not all these changes are necessary and will be dependent upon your usage and hardware. Do some research on settings if you don't understand what they do. These settings are best combined with your standard privacy extensions (HTTPS Everywhere No longer required: Enable HTTPS-Only Mode, NoScript/Request Policy, uBlock origin, agent spoofing, Privacy Badger etc), and all plugins set to "Ask To Activate".

@pradeepdotco
pradeepdotco / rssfeedimage.php
Created October 3, 2015 10:54
Function to add featured image to RSS feed
<?php
add_filter( 'the_content', 'featured_image_in_feed' );
function featured_image_in_feed( $content ) {
global $post;
if( is_feed() ) {
if ( has_post_thumbnail( $post->ID ) ){
$output = get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) );
$content = $output . $content;
}
}
@theankitgaurav
theankitgaurav / functionalArrayMethods.md
Created November 4, 2016 16:37
JavaScript Map, Filter, Reduce methods Cheatsheet

map()

Use it when: You want to translate/map all elements in an array to another set of values.

Example: convert Fahrenheit temps to Celsius.

var fahrenheit = [0, 32, 45, 50, 75, 80, 99, 120];

var celcius = fahrenheit.map(function(elem) {
@ePirat
ePirat / INSTALL.md
Last active April 7, 2023 13:43
Cross-compile libaacs for Windows (64bit)

Cross-compile libaacs for Windows (64bit)

For this guide the ubuntu:yakkety Docker image was used.

Install the cross-compile toolchain

apt-get install mingw-w64-tools gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 wget gettext bison flex
@davidejones
davidejones / Makefile
Created January 19, 2017 16:59
mingw gcc dos compile (thanks to http://nullprogram.com/blog/2014/12/09/)
CFLAGS = -std=gnu99 -Wall -Wextra -Os -nostdlib -m32 -march=i386 \
-Wno-unused-function \
-ffreestanding -fomit-frame-pointer -fwrapv -fno-strict-aliasing \
-fno-leading-underscore \
-Wl,--nmagic,-static,-Tmingw.com.ld
all:
gcc $(CFLAGS) -o hello.o hello.c
objcopy -O binary hello.o hello.com