Skip to content

Instantly share code, notes, and snippets.

@marcgg
marcgg / notevalues.json
Created Nov 1, 2016
note frequency value
View notevalues.json
var noteValues = {
'C0': 16.35,
'C#0': 17.32,
'Db0': 17.32,
'D0': 18.35,
'D#0': 19.45,
'Eb0': 19.45,
'E0': 20.60,
'F0': 21.83,
'F#0': 23.12,
@marcgg
marcgg / gist:733592
Created Dec 8, 2010
Regex to get the Facebook Page ID from a given URL
View gist:733592
# Matches patterns such as:
# https://www.facebook.com/my_page_id => my_page_id
# http://www.facebook.com/my_page_id => my_page_id
# http://www.facebook.com/#!/my_page_id => my_page_id
# http://www.facebook.com/pages/Paris-France/Vanity-Url/123456?v=app_555 => 123456
# http://www.facebook.com/pages/Vanity-Url/45678 => 45678
# http://www.facebook.com/#!/page_with_1_number => page_with_1_number
# http://www.facebook.com/bounce_page#!/pages/Vanity-Url/45678 => 45678
# http://www.facebook.com/bounce_page#!/my_page_id?v=app_166292090072334 => my_page_id
# http://www.facebook.com/my.page.is.great => my.page.is.great
View progress.swift
import SwiftUI
let timer = Timer
.publish(every: 1, on: .main, in: .common)
.autoconnect()
struct Clock: View {
var counter: Int
var countTo: Int
View keybase.md

Keybase proof

I hereby claim:

  • I am marcgg on github.
  • I am marcgg (https://keybase.io/marcgg) on keybase.
  • I have a public key ASDSHW5G88X7EPK9KNVO354Zm_XExZ6qSKYYOk14-d3_YQo

To claim this, I am signing this object:

@marcgg
marcgg / gist:2e57218351e27fcc20c4
Last active Apr 7, 2018
Mapping of country codes with international phone number prefixes, in JSON!
View gist:2e57218351e27fcc20c4
{
"AF": "93",
"AL": "355",
"DZ": "213",
"AD": "376",
"AO": "244",
"AQ": "672",
"AR": "54",
"AM": "374",
"AW": "297",
View notes.rb
class Note
def self.add(player_id, x, y)
key = "note_#{SecureRandom.hex}"
REDIS.set(key, {
x: x, y: y, player_id: player_id
}.to_json)
REDIS.expire(key, 5)
broadcast_note(player_id, x, y)
REDIS.incr("count_notes")
end
View player.rb
class Player
def self.all
REDIS.smembers("player_ids").map do |player_id|
JSON.parse(REDIS.get("player_#{player_id}"))
end
end
def self.add(player_json)
player = JSON.parse(player_json)
raise "Player is blank" if player.blank?
@marcgg
marcgg / generate_scripts.rb
Created Feb 14, 2016
Generating shell scripts
View generate_scripts.rb
run_template = "rvm use 2.2.3
cd FULL_PATH
echo FULL_PATH: STARTED
bundle install
echo FULL_PATH: DONE BUNDLING
rake db:drop RAILS_ENV=test
rake db:create RAILS_ENV=test
rake db:migrate RAILS_ENV=test
echo FULL_PATH: DONE WITH MIGRATIONS
bundle exec rspec spec/controllers/students_controller_spec.rb spec/models/exam_spec.rb spec/models/grade_spec.rb spec/models/student_spec.rb > ../rspec_results.log
View gist:6222393
class BankAccountController
def admin_index
@bbans = Bbans.all
end
def user_index
@bbans_user = current_user.bbans.all
end
View gist:2644116
Content for .zsh:
#########
# COLORS
#########
autoload -U colors
colors
setopt prompt_subst