Skip to content

Instantly share code, notes, and snippets.

@fuse
fuse / deduplicate_1password_items.sh
Created March 26, 2023 16:13
After merging two 1password vaults I ended up with a lot of duplicates. I wanted to only keep one version of each entry.
#!/bin/bash
# This script basically find duplicateds based on titles, keep the first one and delete the other ones.
# /!\ Be careful if you have different IDs that potentially have the same title.
# You need 1password client and jq to make it work
json_data=$(op item list --format json)
duplicates=$(echo "$json_data" | jq -r '.[] | .title' | sort | uniq -d)
while read -r title; do
{
"_json"=>[
{
"farm"=>{
"uid"=>"04a814ed-7041-4b04-a51b-c6bd41c593ca",
"name"=>"demo API dev",
"farm_code"=>"30247504101420"
},
"indicator"=>{
"uid"=>"970d9d0b-37d1-4602-a687-2b8ce6b621e0",
@fuse
fuse / _docker-machine
Created January 28, 2016 10:04
Extend docker-machine to have a use command
#compdef docker-machine
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Docker Machine (http://docs.docker.com/machine/).
# Adapted from boot2docker completion by hhatto (https://github.com/hhatto)
# and docker completion by @aeonazaan and @bobmaerten.
#
# ------------------------------------------------------------------------------
@fuse
fuse / Gemfile
Created October 29, 2013 16:25 — forked from nicoolas25/Gemfile
gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-windowslive'
require 'benchmark'
n = 5000000
class A
def initialize(attribute)
@attribute = attribute
end
@fuse
fuse / named_capture.rb
Created July 3, 2012 12:39
Ruby regex named capture
[1] pry(main)> str = "Candy bar"
=> "Candy bar"
[2] pry(main)> /(?<word>\w+)/ =~ str
=> 0
[3] pry(main)> word
=> "Candy"
[4] pry(main)> str =~ /(?<w>\w+)/
=> 0
[5] pry(main)> w
NameError: undefined local variable or method `w' for main:Object
@fuse
fuse / gist:1759079
Created February 7, 2012 10:51 — forked from tight/gist:1758913
for vs each
i = "foo"
for i in 1..5 do
puts i
j = "bar"
end
i # => 5
j # => "bar"
i = "foo"
(1..5).each do |i|
Last 10 log lines:
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
SOLIBS =
compiling main.c
In file included from /usr/include/string.h:190,
from ./include/ruby/ruby.h:48,
from ./include/ruby.h:32,
from main.c:13:
/usr/include/secure/_string.h: In function ‘__inline_stpncpy_chk’:
/usr/include/secure/_string.h:118: error: implicit declaration of function ‘__builtin___stpncpy_chk’
@fuse
fuse / mysql2
Created January 19, 2012 09:49
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Users/fuse/Dropbox/code/ladw/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info
Referenced from: /Users/fuse/Dropbox/code/ladw/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
upstream fake {
server unix:/www/fake/shared/sockets/unicorn.sock;
}