Skip to content

Instantly share code, notes, and snippets.

/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@AlexKalinin
AlexKalinin / 00_README.md
Created October 29, 2019 16:47 — forked from mikechau/00_README.md
Logging Rails 4 to Syslog, formatted w/ Logstash

Logging Rails 4 to Syslog, formatted w/ Logstash

Getting Started

Steps to get Rails 4 saving its output to Syslog via Rsyslog. This assumes you are on CentOS, but should be pretty adaptable to any other distribution. Ruby 2.0+ is also required.

  1. Add the gems lograge and logstash-event to your Gemfile. Feel free to remove from production if you'd like to test it in development as well or something.
  2. Update production.rb with the lograge settings and set the logger to Syslog::Logger.
  3. Add the conf files to /etc/rsyslog.d/. /etc/rsyslog.conf should have $IncludeConfig /etc/rsyslog.d/*.conf enabled, so it will load any additional configs from /etc/rsyslog.conf.
@AlexKalinin
AlexKalinin / example_multi_level_dsl.rb
Created February 8, 2019 08:42 — forked from ms-ati/example_multi_level_dsl.rb
Example of a recursive multi-level DSL in Ruby using Docile gem
require 'docile'
# Family tree node, mother and father are Person values as well
Person = Struct.new(:name, :mother, :father)
# Recursive dsl in a mutating builder using Docile
def person(&block)
Docile.dsl_eval(PersonBuilder.new, &block).build
end
@AlexKalinin
AlexKalinin / embedded-file-viewer.md
Created November 14, 2018 06:42 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@AlexKalinin
AlexKalinin / index.html
Created September 24, 2018 14:40 — forked from shiawuen/index.html
Sample to upload file by chunk
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>test upload by chunk</title>
</head>
<body>
<input type="file" id="f" />
<script src="script.js"></script>
@AlexKalinin
AlexKalinin / .gitconfig
Created December 26, 2017 06:04 — forked from rambabusaravanan/.gitconfig
Git Diff and Merge Tool - IntelliJ IDEA
# Linux
# add the following to "~/.gitconfig" file
[merge]
tool = intellij
[mergetool "intellij"]
cmd = /usr/local/bin/idea merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
trustExitCode = true
[diff]
@AlexKalinin
AlexKalinin / wav_header.h
Created December 23, 2017 06:35 — forked from Jon-Schneider/wav_header.h
C Wav Header Struct
// WAV header spec information:
//https://web.archive.org/web/20140327141505/https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
//http://www.topherlee.com/software/pcm-tut-wavformat.html
typedef struct wav_header {
// RIFF Header
char riff_header[4]; // Contains "RIFF"
int wav_size; // Size of the wav portion of the file, which follows the first 8 bytes. File size - 8
char wave_header[4]; // Contains "WAVE"
@AlexKalinin
AlexKalinin / custom_logger.rb
Created November 27, 2017 07:17 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@AlexKalinin
AlexKalinin / singleton.js
Last active August 6, 2017 03:05
Javascript Singleton Example
window.AuthApi = (function(){
var instance;
function AuthApiObject(){
uid = Math.random();
return {
foo: function(){
console.log('foo');
},
@AlexKalinin
AlexKalinin / firebase.rb
Created August 4, 2017 19:06
Firebase example, ruby
# https://github.com/oscardelben/firebase-ruby
# https://github.com/firebase/firebase-token-generator-ruby
# Gemfile
# gem 'firebase'
# gem 'firebase_token_generator'
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)