Skip to content

Instantly share code, notes, and snippets.

Bryan bryanwongbh

Block or report user

Report or block bryanwongbh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pdfParser.js
fs = require('fs');
var PDFParser = require("pdf2json/pdfParser");
var pdfParser = new PDFParser(this,1);
pdfParser.on("pdfParser_dataError", errData => console.error(errData.parserError) );
pdfParser.on("pdfParser_dataReady", pdfData => {
console.log("Raw - ");
console.log(pdfParser.getRawTextContent());
@bryanwongbh
bryanwongbh / elasticsearch-lock-only
Created Jan 24, 2019
Elasticsearch Remove Lock Read-Only Mode
View elasticsearch-lock-only
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
@bryanwongbh
bryanwongbh / rails-fixtures-load.rb
Created Jan 22, 2019
Load Rails Fixtures to Test Environment
View rails-fixtures-load.rb
rails db:fixtures:load RAILS_ENV=test FIXTURES=<put fixtures here>
View cloud9-redis-usage.txt
nada-nix install redis
redis-server --port 16379 --bind $IP
./redis-cli -h $IP -p 16379
//Persistent
echo "bind $IP\nport 16379" > redis.conf
@bryanwongbh
bryanwongbh / rspec_model_testing_template.rb
Created Mar 25, 2016 — forked from kyletcarlson/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@bryanwongbh
bryanwongbh / Rails: Rake Create Dummy Users
Created Dec 18, 2012
Rails: Rake Create Dummy Users
View Rails: Rake Create Dummy Users
#This is for Rake to create some dummy users in an app using Rails; sits within /lib/tasks/
namespace :db do
task populate: :environment do
User.create!(name: "Name",
email: "example@example.com",
password: "test123",
password_confirmation: "test123")
99.times do |n|
name = Faker::Name.name
@bryanwongbh
bryanwongbh / Javascript: Google Analytics API
Created Dec 18, 2012
Javascript: Google Analytics API
View Javascript: Google Analytics API
<!-- Google Analytics -->
<script>
var _gaq=[['_setAccount','<%= CONFIG['google_analytics_id'] %>'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
@bryanwongbh
bryanwongbh / Javascript: Detect IE
Created Dec 18, 2012 — forked from padolsey/gist:527683
Javascript: Detect IE
View Javascript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@bryanwongbh
bryanwongbh / Javascript: Linkedin Share Button
Created Dec 18, 2012
Javascript: Linkedin share button
View Javascript: Linkedin Share Button
<script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/Share" data-url="<%= post_url %>" data-counter="right"></script>
@bryanwongbh
bryanwongbh / Javascript: Twitter Tweet Button
Created Dec 18, 2012
Javascript: Twitter tweet button
View Javascript: Twitter Tweet Button
<!-- Twitter tweet button javascript -->
<a href="https://twitter.com/share" class="twitter-share-button" data-url="<%= post_url %>" data-via="bryanwbh" data-related="bryanwbh" data-hashtags="blog">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
You can’t perform that action at this time.