Skip to content

Instantly share code, notes, and snippets.

View draveness's full-sized avatar
🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢

Draven draveness

🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢
View GitHub Profile
@draveness
draveness / monitor_database_record_creation.rb
Last active September 29, 2017 08:52
Monitor FactoryGirl record creation with ActiveSupport notifications
# source: https://robots.thoughtbot.com/debugging-why-your-specs-have-slowed-down
# spec/spec_helper.rb
config.before(:each, :monitor_database_record_creation) do |example|
ActiveSupport::Notifications.subscribe("factory_girl.run_factory") do |name, start, finish, id, payload|
$stderr.puts "FactoryGirl: #{payload[:strategy]}(:#{payload[:name]})"
end
end
def embeds_many_to_has_many(parent, child)
child_key_name = child.to_s.underscore.pluralize
parent.collection.find({}).each do |parent_document|
next unless parent_document[child_key_name]
parent_document[child_key_name].each do |child_document|
new_child = child_document.merge(
"#{parent.to_s.underscore}_id": parent_document['_id']
)
child.collection.insert_one new_child
end

Keybase proof

I hereby claim:

  • I am Draveness on github.
  • I am draven (https://keybase.io/draven) on keybase.
  • I have a public key whose fingerprint is 62CA 63CD FC29 5526 5B5E 9141 30B1 E305 0480 F92E

To claim this, I am signing this object:

//
// Token.swift
// XProject
//
// Created by Draveness on 05/04/2017.
// Copyright © 2017 Draveness. All rights reserved.
//
import Foundation
import RbSwift
require 'csv'
require 'uri'
require 'pry'
csv_text = File.read('1.csv')
csv = CSV.parse(csv_text, :headers => true)
hashes = []
csv.each do |row|
hash = row.to_hash
old = hash["old"]
@draveness
draveness / fishhook-test-viewcontroller
Last active September 1, 2016 02:58
Using fishhook to change socket layer function and failed because of recursive call
#import "ViewController.h"
#import <fishhook.h>
@interface ViewController () <NSURLSessionDataDelegate>
@end
@implementation ViewController
int (*origianl_connect)(int, const struct sockaddr *, socklen_t);
@draveness
draveness / 0_reuse_code.js
Created January 14, 2016 04:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console