Skip to content

Instantly share code, notes, and snippets.

View joshuapinter's full-sized avatar
🎯
Focusing

Joshua Pinter joshuapinter

🎯
Focusing
View GitHub Profile
@vitorbritto
vitorbritto / rm_mysql.md
Last active May 7, 2024 09:59
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql
    
@szydan
szydan / gist:b225749445b3602083ed
Last active February 5, 2024 15:16
<U+FEFF> character showing up in files. How to remove them?
1) In your terminal, open the file using vim:
vim file_name
2) Remove all BOM characters:
:set nobomb
3) Save the file:
:wq
@iamatypeofwalrus
iamatypeofwalrus / add_milliseconds_to_mysql_and_activerecord_timestamps.md
Last active February 2, 2024 15:38
ActiveRecord: Store Milliseconds (or Microseconds) in Timestamps/Datetimes with Rails / MySQL

ActiveRecord: Store Milliseconds (or Microseconds) in Timestamps with Rails / MySQL

Milliseconds in your Timestamps.

We got 'em, you want 'em.

Why

Shit needs to be PRECISE

LICENSE

MIT

@bendyorke
bendyorke / benchmark.rb
Created May 20, 2014 06:54
Benchmarking sampling of a hash
require "benchmark"
n = 10000
arr = (1..1000).to_a
zip = arr.zip arr
hash = Hash[zip]
Benchmark.bm do |x|
x.report("%-30s" %["sampling array"]) { n.times do
arr.sample
@yoon
yoon / gist:8876313
Last active September 28, 2023 13:06
zip a folder with rubyzip
require 'rubygems'
require 'zip'
archive_directory_path = ''
archive_zip_path = ''
Zip::File.open( archive_zip_path, Zip::File::CREATE ) do |zip_file|
Dir[ File.join( archive_directory_path, "**", "**" ) ].each do |file|
zip_file.add( file.sub( "#{ archive_directory_path }/", "" ), file )
end
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active April 30, 2024 23:36
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@caleb531
caleb531 / snap-to-grid.js
Last active May 21, 2018 08:37
Makes a jCanvas layer draggable along a defined grid
// Available in jCanvas v20.1.0
// The pixel multiple to snap to
var snapToAmount = 40;
// Round the given value to the nearest multiple of n
function nearest(value, n) {
return Math.round(value / n) * n;
}
$('canvas').drawArc({
layer: true,
@stevenharman
stevenharman / defaults.rb
Last active July 7, 2021 14:36
A subtle difference between Ruby's Hash.fetch(:key, :default) vs. (Hash[:key] || :default)
h = {
'a' => :a_value,
'b' => nil,
'c' => false
}
h.fetch('a', :default_value) #=> :a_value
h.fetch('b', :default_value) #=> nil
h.fetch('c', :default_value) #=> false
h.fetch('d', :default_value) #=> :default_value
@tenbits
tenbits / exif-date-touch.js
Last active April 13, 2024 18:30
nodejs script to set a file modification date from EXIF
/**
* Change file modification time to the date from EXIF
*
* System Requirements:
*
* > npm install -g includejs
* > npm install -g exif
*
* Usage:
*
@daronco
daronco / have_attr_accessor.rb
Created November 23, 2012 00:13
Shoulda matcher have_attr_accessor
# Ensures the model has an attr_accessor, attr_reader or attr_writer
# Examples:
# it { should have_attr_accessor(:value) }
# it { should have_attr_accessor(:value).read_only }
# it { should have_attr_accessor(:value).write_only }
module Shoulda
module Matchers
module ActiveModel # :nodoc
def have_attr_accessor(attribute)