Skip to content

Instantly share code, notes, and snippets.

Avatar

yaojie causztic

View GitHub Profile
@dohomi
dohomi / app.vue
Last active Aug 21, 2020
Small file input element based on vuetify
View app.vue
<template>
<file-input v-model="filename" @formData="formData">
<v-btn @click.native="uploadFiles">
</template>
<script>
import fileInput from './file-input.vue'
export default{
components:{fileInput}
@sobstel
sobstel / nokogiri_install
Created Jan 3, 2017
nokogiri -> ERROR: cannot discover where libxml2 is located on your system
View nokogiri_install
# `ERROR: Error installing nokogiri:
# ERROR: Failed to build gem native extension.
#
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --use-system-libraries
# checking if the C compiler accepts ... yes
# checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
# Building nokogiri using system libraries.
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
# *** extconf.rb failed ***
@wesbos
wesbos / gulpfile.js
Last active Oct 21, 2019
FAST Browserify + Reactify + Babelify
View gulpfile.js
// Update: Hey Folks - I've got a full Gulpfile with everything else over at https://github.com/wesbos/React-For-Beginners-Starter-Files
var source = require('vinyl-source-stream');
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var reactify = require('reactify');
var babelify = require('babelify');
var watchify = require('watchify');
var notify = require('gulp-notify');
@mlanett
mlanett / rails http status codes
Last active Sep 18, 2020
HTTP status code symbols for Rails
View rails http status codes
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@blacktm
blacktm / install_ruby_rpi.sh
Last active Sep 7, 2020
A Bash script to install Ruby 2.6 on the Raspberry Pi (Raspbian)
View install_ruby_rpi.sh
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby 2.6 using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Welcome message
@rogercampos
rogercampos / clockwork.rb
Created Sep 6, 2012
Capistrano running clockwork as daemon
View clockwork.rb
after "deploy:stop", "clockwork:stop"
after "deploy:start", "clockwork:start"
after "deploy:restart", "clockwork:restart"
namespace :clockwork do
desc "Stop clockwork"
task :stop, :roles => clockwork_roles, :on_error => :continue, :on_no_matching_servers => :continue do
run "if [ -d #{current_path} ] && [ -f #{pid_file} ]; then cd #{current_path} && kill -INT `cat #{pid
_file}` ; fi"
end
@dblock
dblock / mongoid_criteria.rb
Created May 24, 2012
Mongoid::Criteria each_by iterator
View mongoid_criteria.rb
module Mongoid
class Criteria
def each_by(by, &block)
idx = 0
total = 0
set_limit = options[:limit]
while ((results = ordered_clone.limit(by).skip(idx)) && results.any?)
results.each do |result|
return self if set_limit and set_limit >= total
@austenito
austenito / integration_spec.rb
Created Apr 11, 2012
Integration Testing w/ Sorcery
View integration_spec.rb
describe "Shopping Cart Requests" do
let!(:user) { Fabricate(:user) }
before(:each) do
login_user_post("admin", "admin")
end
context "when I visit the shopping cart" do
it " show the logged in users' cart items " do
#Test stuff
@nz
nz / configuring tire for bonsai.md
Last active Oct 1, 2015
Configuring Tire to work with Bonsai
View configuring tire for bonsai.md

1. Configure Tire to use the Bonsai ElasticSearch Heroku add-on

gem 'tire'

config/initializers/bonsai.rb

ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
@kirs
kirs / avatar_uploader.rb
Created Sep 24, 2011
Validation of image dimensions with CarrierWave
View avatar_uploader.rb
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# Override the directory where uploaded files will be stored.
You can’t perform that action at this time.