Skip to content

Instantly share code, notes, and snippets.

View ifyouseewendy's full-sized avatar

Di Wen ifyouseewendy

View GitHub Profile
@ifyouseewendy
ifyouseewendy / use-sprockets-ouside-rack-application.rake
Created March 28, 2017 21:42
Use Sprockets outside Rack application. I'm working on a script project which is non Rack based. I want to send users an email notification when the script detects a state change. To use Sprockets outside a Rack application is not a common case, so there are not many articles talking about it online. You could count on this.
desc 'Compile scss files using Sprockets
+ source file: #{root}/lib/assets/stylesheets/application.scss,
in which you could require the third party assets
+ output file: #{root}/build/emai.css
'
task :compile do
require 'third_party_assets'
root = '~/Workspace/project/'
@ifyouseewendy
ifyouseewendy / pre-push.sh
Last active May 18, 2017 15:26
A hook script to do code checking, linting and testing before git push. Change pre-push.sh to pre-push before use.
#!/bin/bash
# http://misc.flogisoft.com/bash/tip_colors_and_formatting
color_echo () {
echo -e "\033[1;97;44m==> $1 \033[m"
}
color_echo "yarn lint"
yarn lint
rp, wp = IO.pipe
mesg = "ping "
20.times { |i|
print "##{i} "
rs, ws, = IO.select([rp], [wp])
require'pry-byebug';binding.pry
if r = rs[0]
ret = r.read(5)
print ret
case ret
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 1 column, instead of 3 in line 5.
Sample time from 2018-09-25 04:00:00 -0400 to 2018-09-25 04:01:00 -0400
--> COUNT CHECK
All 1381 flow runs are found in flow run statuses
--> STATUS CHECK
There are 1381 records with different status
flow_run_uuid, flow_run, flow_run_status
06439fb2-b667-435e-88c9-bd7f4d619fb9-21127, complete, init
0d4a80e0-799f-470e-9831-0afc820612fa-16320, complete, running
require "bundler/setup"
require "kafka"
def foo(msg)
puts "=="*50
kafka = Kafka.new(
seed_brokers: ["shopify.railgun:9092"],
client_id: "flow_rails_whatever",
logger: Logger.new(STDOUT)
)
require "bundler/setup"
require "kafka"
def foo(msg)
puts "=="*50
kafka = Kafka.new(
seed_brokers: ["shopify.railgun:9092"],
client_id: "flow_rails_whatever",
logger: Logger.new(STDOUT)
)
@ifyouseewendy
ifyouseewendy / use-trait-bound-to-implement-generic-find_largest.rs
Created December 7, 2019 18:05
Use **Trait Bound** to implement a generic find largest function. Referenced from https://doc.rust-lang.org/book/ch10-02-traits.html
fn find_largest_1<T: PartialOrd + Copy>(list: &[T]) -> T {
let mut largest = list[0];
for number in list {
if *number > largest {
largest = *number;
}
}
largest
use std::collections::HashMap;
macro_rules! impl_attrs {
() => {
pub fn get_attr(&self, key: &str) -> Option<&str> {
self.attrs.get(key).map(|s| s.as_str())
}
pub fn with_attrs(mut self, attrs: &[(&str, &str)]) -> Self {
self.attrs = attrs
@ifyouseewendy
ifyouseewendy / README-Template.md
Created February 26, 2020 18:34 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ifyouseewendy
ifyouseewendy / serializer_benchmarks.rb
Created April 29, 2020 19:11 — forked from aishfenton/serializer_benchmarks.rb
Performance comparison of different ruby serializer methods
# sudo gem install bson
# sudo gem install bson_ext
# sudo gem install yajl-ruby
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'bson'