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 | |
today=`date +%Y%m%d` | |
#source /etc/profile | |
cd /home/automation/UlineUserImport | |
if [ "$1" == "" ] | |
then | |
echo "" | |
echo "Usage: run [program]" |
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
input = "a, b, c\nd, e, f\ng, h, i\n" | |
lines = input.split("\n") | |
rows = lines.map { |l| l.gsub(/ *, */, ' | ') } | |
col_count = rows.first.scan(/\|/).count + 1 | |
with_header = rows.insert(1, "|#{'---|' * col_count}") | |
output = with_header.join("\n") | |
puts "output:\n#{output}" |
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
defmodule ZteCdmaCdr do | |
defstruct type: nil, | |
sequence_number: nil, | |
call_reference: nil | |
def parse(line) do | |
<< type :: size(11) - binary, | |
sequence_number :: size(12) - binary, | |
call_reference :: size(12) - binary, |
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
class Counters | |
def initialize | |
@h = Hash.new(0) | |
end | |
def increment(key, value = 1) | |
@h[key] += value |
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
public class ChangeBase { | |
public static void main(String[] args) { | |
short[][] shorts = { { 0x00, 0x28 }, { 0x10, 0x28 }, { 0x1F, 0x9C } }; | |
int iterations = 102533960; | |
long start = System.nanoTime(); | |
for (int i = 0; i < iterations; i++) { | |
for (short[] s : shorts) { | |
convertToIntegerUsingStringManipulation(s); | |
} |
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
public class ChangeBase { | |
public static void main(String[] args) { | |
short[][] shorts = { { 0x00, 0x28 }, { 0x10, 0x28 }, { 0x1F, 0x9C } }; | |
for (short[] s : shorts) { | |
System.out.println(s[0] << 8 | s[1] & 0xFF); | |
} | |
} | |
} |
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 | |
# A simple script to backup an organization's GitHub repositories. | |
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files | |
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up | |
# (if you're backing up a user's repos instead, this should be your GitHub username) | |
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API) | |
GHBU_PASSWD=${GHBU_PASSWD-"<CHANGE-ME>"} # the password for that account | |
GHBU_GITHOST=${GHBU_GITHOST-"github.com"} # the GitHub hostname (see comments) | |
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted |
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'date' | |
data = Hash.new(0) | |
Dir.glob("#{ARGV[0]}/**/*").reject { |f| File.directory?(f) }.each do |file| | |
date = Date.parse(file[/\d{4}\/\d{2}\/\d{2}/]) | |
size = File.size(file) | |
data[date] += size | |
end |
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
source lock_file_library.sh | |
# acquire the lock | |
acquire_lock_for "maintenance" | |
# your code's critical section | |
echo "Running maintenance." | |
# release your lock | |
release_lock_for "maintenance" |
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
# dP | |
# 88 | |
# 88 .dP .d8888b. dP dP dP dP dP .d8888b. dP dP | |
# 88888" 88ooood8 88 88 88 88 88 88' `88 88 88 | |
# 88 `8b. 88. ... 88. .88 88.88b.88' 88. .88 88. .88 | |
# dP `YP `88888P' `8888P88 8888P Y8P `88888P8 `8888P88 | |
# .88 .88 | |
# d8888P d8888P | |
# | |
# A simple lock file library. |