Skip to content

Instantly share code, notes, and snippets.

View fervic's full-sized avatar

Roberto Fernandez fervic

View GitHub Profile
@egelev
egelev / connect_bluetooth_headphones.sh
Last active April 26, 2024 14:14
Connect bluetooth headphones on Ubuntu 18.04
#!/usr/bin/env bash
function get_headphones_index() {
echo $(pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}')
}
function get_headphones_mac_address() {
local temp=$(pacmd list-cards | grep bluez_card -C20 | grep 'device.string' | cut -d' ' -f 3)
temp="${temp%\"}"
temp="${temp#\"}"
@andelf
andelf / sighup.go
Created June 29, 2013 05:25
golang process SIGHUP, HUP signal to reload configuration
// program
package main
import "os/signal"
import "os"
import "fmt"
import "syscall"
import "time"
def insert_big_arsed_table(array_of_values, created_date)
sql = "COPY big_arsed_table (other_table_id, other_id, other_type, created_at, updated_at) from STDIN WITH DELIMITER AS ',' "
ActiveRecord::Base.connection_pool.with_connection do |conn|
rc = conn.raw_connection
begin
rc.exec(sql)
loop_time = Benchmark.ms do
@ged
ged / copyfrom.rb
Created September 28, 2010 15:45
Example of how to use COPY FROM from Ruby with the 'pg' library. The last two edits are demonstrating the error case and the successful case.
#!/usr/bin/env ruby
require 'pg'
require 'stringio'
$stderr.puts "Opening database connection ..."
conn = PGconn.connect( :dbname => 'test' )
conn.exec( <<END_SQL )
DROP TABLE IF EXISTS logs;