This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# gnome-screenshot-imgur | |
# Upload a screenshot directly to imgur from CLI; see `man gnome-screenshot` for | |
# params (-f is reserved) | |
# | |
# Generate temp file for image | |
tmp=$(mktemp --suffix=.png) | |
# Take screenshot as per user's params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCRIPT=$(basename "$0") | |
DELETED=$HOME/deleted | |
# Ensure mandatory files/directories exist | |
touch $HOME/.restore.info | |
mkdir -p $DELETED | |
# Parse options | |
while getopts "ivr" opt; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('undefined' === typeof ga) { | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | |
} | |
ga('create', 'UA-60598043-2', 'auto', {'allowLinker': true, 'name': 'oc'}); | |
ga('oc.require', 'linker'); | |
ga('oc.linker:autoLink', ['primary.co.uk']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Count duplicates in an array before and after each element. | |
* | |
* <code> | |
* $counts = count_duplicates_both_ways([0, 1, 1, 2, 2, 1]); | |
* print_r($counts); | |
* // [ | |
* // 'before' => [0, 0, 1, 0, 1, 2], | |
* // 'after' => [0, 2, 1, 1, 0, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Execute a command if the user is idle for a specified period of time | |
# Requires: xprintidle | |
# Usage: if-idle IDLE_MIN IDLE_COMMAND [NOT_IDLE_COMMAND] | |
# | |
IDLE_MIN=$1 | |
IDLE_TIME=$(xprintidle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
class Solution { | |
public static int solve(int[] A, int[] B) { | |
int i = 0; | |
int j = 0; | |
Arrays.sort(A); | |
Arrays.sort(B); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
class Solution { | |
public static int solve(int[] A, int n) { | |
HashMap<Integer, Integer> counts = new HashMap<Integer, Integer>(); | |
int i; | |
for (int a : A) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function solution($A, $B) { | |
// Build an array relating maximum circumferences to depths | |
$smallest_at = [-1 => PHP_INT_MAX]; | |
for ($i = 0; $i < count($A); $i++) { | |
$smallest_at[$i] = min($smallest_at[$i - 1], $A[$i]); | |
} | |
// Start dropping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Yields the list of differences between a list of datetimes. | |
* @param array $dates An ordered list of datetimes of which to find the | |
* differences. | |
* @return array The differences between each sequential datetime in $dates. | |
*/ | |
function date_diffs($dates) { | |
$diffs = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function iscmd() | |
{ | |
if hash $1 2>/dev/null; then | |
return 0 | |
fi | |
return 1 | |
} | |
iscmd $1 |
OlderNewer