Skip to content

Instantly share code, notes, and snippets.

work work work

Alexii Carey elchingon

work work work
View GitHub Profile
elchingon / ir-optical-sensor-pi
Created Aug 27, 2019
Code to detect motion on Raspberry Pi with Miniature Reflective Infrared Optical Sensors - ITR20001/T from Adafruit
View ir-optical-sensor-pi
import logging
import datetime
from time import sleep
from gpiozero import MotionSensor
pir = MotionSensor(4, pull_up=True, sample_rate=200, threshold=0.2)
datetime_set = False
elchingon / rails-5-initializer-commands
Last active Jan 13, 2019
Rails 5 Initialize commands for Doorkeeper, Devise, Rolify, Rspec
View rails-5-initializer-commands
# Create Rails App
rails new app_name -d mysql
### cp config/database.example.yml
rake db:create
# this needs to be run in crrent process with the "dot" command
# . ims|opc
printf "\e]1;${1-$(basename `pwd`)}\a"
case $tabname in
cd '/Users/xxxxxx/Sites/tayda/tayda_inventory'
elchingon / method_logger.rb
Last active Mar 12, 2018
Logger class that will allow custom logger name within instance and class methods of other ruby classes.
View method_logger.rb
# include in Ruby / Active Record class
# include MethodLogger
# logger_name("ticket_logger")
# use as a standard rails logger
#" Events Processed: #{events_processed}")
# ticket_logger.error(e.inspect)
elchingon / upgrade_rails.rb
Created Feb 5, 2018
Upgrade Rails 4 to Rails 5
View upgrade_rails.rb
#! /usr/bin/env ruby
filenames = Dir["app/models/*.rb"]
filenames.each do |file_name|
next if file_name.include? 'application_record.rb'
text =
new_contents = text.gsub(/< ActiveRecord::Base/, "< ApplicationRecord")
if text != new_contents
p "changing #{file_name}"
# To merely print the contents of the file, use:
elchingon / old_file_killer.rb
Created Jan 9, 2018 — forked from pelgrim/old_file_killer.rb
A Ruby script to delete files older than X days in a given directory.
View old_file_killer.rb
#!/usr/bin/env ruby
# A Ruby script to delete files older than X days in a given directory. Pretty simple.
# Like this: file_control.rb /User/pelgrim/Documents '*.pdf' 7
# The command above you remove ALL your pdfs inside Documents older than SEVEN DAYS.
# Quickly written by pelgrim < guskald at gmail dot com >
unless ARGV.size == 3
puts "Usage: file_control <directory> <filename pattern> <max age>"
exit 1
View Replace spec_helper with rails_helper
# get a list of files which contain "require" AND "spec_helper" on a single line
# excluding spec/rails_helper.rb (we want "require 'spec_helper'" to exist here)
declare -a files=$(git grep -E "require.*spec_helper" | cut -d ':' -f 1 | grep -v 'spec/rails_helper.rb')
# loop through files and replace "spec_helper" with "rails_helper"
for i in $files; do
sed -i '' -e 's/spec_helper/rails_helper/' $i
# 1. Clear retry set
# 2. Clear scheduled jobs
# 3. Clear 'Processed' and 'Failed' jobs
View Full-circle-js README
Adding Events to Site
There are 4 different viewTypes that pass events or coupons based on adId or organizationId.
{ viewType: eventsForAd, adId: 360APIAdId, limit: LIMIT} -- limit is optional
{ viewType: couponsForAd, adId: 360APIAdId }
{ viewType: couponsSmallForAd, adId: 360APIAdId }
{ viewType: eventsForOrganization, organizationId: 360DurangoAPIOrganizationId }
{ viewType: adsForOrganization, organizationId: 360DurangoAPIOrganizationId }
elchingon / sidekiq-init.d.txt
Last active Jan 11, 2017
Ubuntu Sidekiq Service Init.d script
View sidekiq-init.d.txt
--- /etc/init.d/sidekiq - SAVE File
# sidekiq Init script for Sidekiq
# chkconfig: 345 100 75
# Description: Starts and Stops Sidekiq message processor for Stratus application.
# User-specified exit parameters used in this script:
You can’t perform that action at this time.