Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark J. Lehman supremebeing7

View GitHub Profile
@supremebeing7
supremebeing7 / console.rb
Created Jul 13, 2018
datetime comparison
View console.rb
001 > User.where('created_at >= ?', '2018-07-12T17:12:37.673+02:00')
User Load (0.5ms) SELECT "users".* FROM "users" WHERE (created_at >= '2018-07-12T17:12:37.673+02:00') LIMIT ? [["LIMIT", 11]]
=> #<ActiveRecord::Relation [#<User id: 1, username: "stuff", email: "m@c.com", password_hash: "4dc594e728edf9acd0148eb195e09af68a082ff6", password_salt: "9225fe40b42187ff1fc440b2c32cf2fba67e3be7", created_at: "2018-07-13 04:56:44", updated_at: "2018-07-13 04:56:44">]>
002 > User.where('created_at <= ?', '2018-07-12T17:12:37.673+02:00')
User Load (0.5ms) SELECT "users".* FROM "users" WHERE (created_at <= '2018-07-12T17:12:37.673+02:00') LIMIT ? [["LIMIT", 11]]
=> #<ActiveRecord::Relation []>
003 > user.created_at
=> Fri, 13 Jul 2018 04:56:44 UTC +00:00
@supremebeing7
supremebeing7 / parser.rb
Created Apr 22, 2018
roo gem parse issues
View parser.rb
require 'roo'
csv = Roo::Spreadsheet.open("sample.csv")
csv.parse
# => [["row1col1", "row1col2", "row1col3"],
# ["row2col1", "row2col2", "row2col3"],
# ["row3col1", "row3col2", "row3col3"]]
csv.parse(headers: true)
View Theming-Slack-OSX.md

Theming Slack for OSX

So, you love Slack, but you hate applications with large white backgrounds? Why not use Dark Mode!

Unfortunately, Slack does not have a Dark Mode, although it's on their list of possibilities.

But, don't fret - there is a solution! Because the slack native desktop apps are just wrappers around a web app, we can load our own CSS to customize the application to our liking.

How to (OSX Only)

@supremebeing7
supremebeing7 / set-modified-to-creation-date.sh
Created Nov 14, 2016
Set file modified date to creation date for fileset
View set-modified-to-creation-date.sh
# This doesn't work in its current form... I don't remember what the problem is
for i in $( ls ); do
if [ "$i" == "DSC_0518.JPG" ]; then
modified=\"$(GetFileInfo -m $i)\"
SetFile -d \'$modified\' $i
fi
done
count=1
for i in $( ls ); do
View mina-nvm.rb
require 'mina/git'
require 'json'
set :domain, '0.0.0.0'
set :user, 'nodejs'
set :deploy_to, '/home/nodejs/api'
set :repository, 'git@.../api.git'
set :branch, 'master'
set :shared_paths, [ 'tmp' ]
set :term_mode, :pretty
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View .bash_profile
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gcm='git commit -m'
alias gd='git diff'
alias gco='git checkout '
alias gcob='git checkout -b '
alias got='git '
View Locales.yaml
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
View Preferences.sublime-settings
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
@supremebeing7
supremebeing7 / report.rake
Created Sep 10, 2014
Rake task testing with Rspec
View report.rake
namespace :report do
task :daily => :environment do
report_for_all_users('daily_report', 'day')
end
def report_for_all_users(flag, time_period)
puts "Getting users who want #{flag.to_s.humanize}s"
users = User.where("admin = true AND settings -> '#{flag}' = '1'")
puts "Sending #{flag.to_s.humanize}s for #{users.count} users"
users.each do |user|
You can’t perform that action at this time.