Skip to content

Instantly share code, notes, and snippets.

Avatar

Garrett O'Reilly goreilly

  • San Francisco, CA
View GitHub Profile
@goreilly
goreilly / dedupe.ps1
Created May 30, 2020
Remove duplicate files with same filename but different extension in powershell
View dedupe.ps1
Add-Type -AssemblyName Microsoft.VisualBasic
$items = Get-ChildItem -Path . -Recurse -Name "*.opus"
foreach ($item in $items) {
#Write-Host $item
$base = $item.Substring(0, $item.LastIndexOf('.'))
$ogg = $base + ".ogg"
@goreilly
goreilly / color.kt
Created Feb 1, 2018
Parse CSS colors in Kotlin
View color.kt
class Color(val red: Int, val green: Int, val blue: Int, val alpha: Float) {
companion object {
private val pattern = Pattern.compile("^rgba?\\((\\d+), (\\d+), (\\d+)(?:, ([\\d.]+))?\\)$")
fun fromString(string: String): Color? {
val matcher = pattern.matcher(string)
if (!matcher.matches()) return null
View fixed-table-width-list.sass
@mixin child-widths($widths)
@for $i from 1 through length($widths)
$width: nth($widths, $i)
&:nth-child(#{$i})
width: $width
table.fixed
th, td
@include child-widths(100px 20px 10px 20px 20px)
View rmagick_code128b.rb
def code128spec(string)
lookup = %w(
\ ! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9
: ; < = > ? @
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
[ \\ ] ^ _ `
a b c d e f g h i j k l m n o p q r s t u v w x y z
{ | } ~ )
@goreilly
goreilly / dif.php
Created Jan 10, 2017
Generate Data Interchange Format from key value array source
View dif.php
<?php
$data = [
[
'hello' => 'world',
'world' => 'hello',
],
[
'hello' => '12387293871293847123894712342134',
'world' => '12387293871293847123894712342134',
@goreilly
goreilly / .my.cnf
Created Oct 25, 2016
Import entire MySQL databases from command live over SSH tunnel
View .my.cnf
[client]
user=root
password=password
host=127.0.0.1
port=3306
[clientremote]
user=remote_username
password=remote_password
host=127.0.0.1
port=3307
@goreilly
goreilly / Batch manage and version host keys with ansible.md
Last active Oct 7, 2016
Batch manage and version host keys with ansible
View Batch manage and version host keys with ansible.md

Batch manage and version host keys with ansible

$ ansible-playbook tool_known_hosts.yml

./tool_known_hosts.yml

---
- hosts: localhost
@goreilly
goreilly / composer.json
Last active Sep 22, 2016
ansible generate symfony parameters.yml
View composer.json
{
"require": {
"symfony/yaml": "2.2"
}
}
View ansible_custom_template.yml
---
##
# Invoke any type of script to modify files. Dry-run friendly usually.
# remote_path: Path to file on server.
# script: Commands that returns altered content on stdout
##
- name: get current content
always_run: yes
register: remote
View keybase.md

Keybase proof

I hereby claim:

  • I am goreilly on github.
  • I am goreilly (https://keybase.io/goreilly) on keybase.
  • I have a public key whose fingerprint is FB90 8739 39D7 552B 633A 69F4 3878 74DE 3207 89A9

To claim this, I am signing this object:

You can’t perform that action at this time.