Skip to content

Instantly share code, notes, and snippets.

View christos's full-sized avatar

Christos Zisopoulos christos

View GitHub Profile

To symlink SSH_AUTH_SOCK on boot to system-wide switch the value from default ssh agent:

  1. Change /opt/homebrew/ to the correct homebrew path (/opt/homebrew is for Apple Silicon and /usr/local for x86)
  2. Change the ssh agent as needed, this example uses https://github.com/FiloSottile/yubikey-agent
  3. Save as ~/Library/LaunchAgents/link-ssh-auth-sock.plist
  4. Run launchctl load -F ~/Library/LaunchAgents/link-ssh-auth-sock.plist

Technique taken from: https://evilmartians.com/chronicles/stick-with-security-yubikey-ssh-gnupg-macos

@christos
christos / gist:9616652
Last active June 20, 2018 22:31 — forked from samwgoldman/gist:9610193
Presigned S3 urls
access_key_id = ENV.fetch("APP_S3_ACCESS_KEY_ID")
secret_access_key = ENV.fetch("APP_S3_SECRET_ACCESS_KEY")
bucket_name = ENV.fetch("APP_S3_BUCKET")
s3 = AWS::S3.new(access_key_id: access_key_id, secret_access_key: secret_access_key)
bucket = s3.buckets[bucket_name]
object = bucket.objects["whatever/you/want"]
presign = AWS::S3::PresignV4.new(object)
presign.presign(:put, expires: 15.minutes.from_now.to_i)
# => #<URI::HTTP:0x007fcfcd97e1a0 URL:***stuff***>
require 'benchmark/ips'
require 'redis'
class MethodProfiler
def self.patch(klass, methods, name)
patches = methods.map do |method_name|
<<~RUBY
unless defined?(#{method_name}__mp_unpatched)
alias_method :#{method_name}__mp_unpatched, :#{method_name}
def #{method_name}(*args, &blk)
unless prof = Thread.current[:_method_profiler]
default: &default
adapter: mysql2
encoding: utf8mb4
username: root
password:
host: localhost
variables:
sql_mode: TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY
development:

##alt text GistList: TODO for coders alt text

def build_path
"build/iPhoneOS-6.0-Release/"
end
def ipa_name
'"Today\'s Shirts.ipa"'
end
def dsym_name
'"Today\'s Shirts.dSYM"'
# in rails application.rb
initializer "postgresql.no_default_string_limit" do
ActiveSupport.on_load(:active_record) do
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:string].delete(:limit)
end
end
RSpec.configure do |config|
config.around do |example|
# For examples using capybara-webkit for example.
# Remove this if you don't use it or anything similar
if example.metadata[:js]
example.run
ActiveRecord::Base.connection.execute("TRUNCATE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY")
else
ActiveRecord::Base.transaction do
@christos
christos / README.md
Created November 27, 2015 15:04 — forked from wvengen/README.md
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@christos
christos / osx-for-hackers.sh
Created November 13, 2015 15:40 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'