Skip to content

Instantly share code, notes, and snippets.

View aschyiel's full-sized avatar

Ulysses Levy aschyiel

View GitHub Profile
@aschyiel
aschyiel / randomize_activities
Created June 19, 2015 23:06
Randomize PublicActivity::Activity
# Randomize the activity dates for testing purposes.
PublicActivity::Activity.all.each { |it| it.update(created_at: Faker::Date.between(1.year.ago, Date.today)) }
@aschyiel
aschyiel / pseudo_sensors_osx.sh
Created September 8, 2015 21:47
pseudo sensors for osx
# After installing the "iStats" gem;
# Add the following line to ~/.bashrc
# see http://apple.stackexchange.com/a/127453/145556
alias sensors='istats | grep -v "Unknown temp" | grep -v "??" | grep -v "\-127" | tail -r'
{
"added_words":
[
"pio",
"namespace",
"indices",
"clientside"
],
"color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
"detect_indentation": false,
"
" Uly's .vimrc
"
" references:
" http://tottinge.blogsome.com/use-vim-like-a-pro
" https://raw.github.com/nvie/vimrc/master/vimrc
" http://spf13.com/post/the-15-best-vim-plugins
"
set nocompatible "..set not compatible first!..
@aschyiel
aschyiel / google-login-example.js
Created October 4, 2016 00:06
casperJS google login example
// Also see http://stackoverflow.com/questions/35822029/casperjs-google-login-not-working
const env = require('system').env;
const google_email = env.MY_GOOGLE_EMAIL;
const google_passwd = env.MY_GOOGLE_PASSWD;
var casper = require('casper').create();
casper.start('https://accounts.google.com/ServiceLogin?hl=EN', function() {
casper.waitForSelector('form#gaia_loginform #Email', function() {
@aschyiel
aschyiel / got.rb
Created October 17, 2016 23:33
A ruby analog of lodash#get.
module MyModuleName
# Safely navigate a hashmap via dot-notation, similar to lodash#get.
# May return nil; Assumes string keys, will not work for symbols!
#
# Example Usage:
# got(foo, 'bar.fizz.buzz')
def got(object, dot_notation_path, default_value = nil)
# FIXME: Does not support OpenStruct! -uly, july 2016
keys = dot_notation_path.split('.')
while !keys.empty? && !object.nil?
@aschyiel
aschyiel / microsoft_excel_is_a_pile_of_shit_and_bill_gates_knows_it_da_doy.rb
Created November 7, 2017 20:04
How to insert newlines into strings when working with excel in ruby (Focus on Science, Morty!)
POOR_MANS_LINE_BREAK = '__br__'
# How to insert newlines into strings when working with excel in ruby.
#
# NOTE: There are probably better ways of doing this, but this works for me. -uly, oct 2017
#
# See https://stackoverflow.com/questions/14856501/substitute-a-comma-with-a-break-link-in-a-cell
# GOTCHA: Careful to guard against blank strings; breaks excel and will result in a "repair".
def insert_newlines_into_excel_value_if_any(s)
s = "=SUBSTITUTE(\"#{ s.gsub(/\n/, POOR_MANS_LINE_BREAK) }\", \"#{ POOR_MANS_LINE_BREAK }\", CHAR(13))" if s =~ /\n/
@aschyiel
aschyiel / slick.js.jsx
Created March 8, 2019 18:29
POC slick input wrapper
/**
* Slick UX for displaying text while allowing focus input.
*/
const React = require('react');
const classNames = require('classnames');
module.exports = React.createClass({
getInitialState() {
return {
'toggled': false