This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rails_helper' | |
| class Validatable | |
| include ActiveModel::Validations | |
| attr_accessor :data | |
| validates :data, lead_data: true | |
| end | |
| describe DataValidator do | |
| subject { Validatable.new } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd ~/Desktop/wallpapers | |
| # find the available files | |
| photos=`find ${PWD} -type f -maxdepth 2 -name "*.jpg" -o -name "*.png"` | |
| # Select Random photos | |
| numlines="$(printf "%s\n" "${photos}" | wc -l)" | |
| lineno="$((${RANDOM} % ${numlines} + 1))" | |
| random_line="$(printf "%s\n" "${photos}" | sed -n "${lineno}{p;q;}")" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # run it using bash <(curl https://gist.githubusercontent.com/yihyang/0186b3b0817f8ea4f0014ea3380e661a/raw) | |
| ########## | |
| # docker # | |
| ########## | |
| # setup docker | |
| docker run -it -d -p 80:80 kdelfour/cloud9-docker | |
| ######## | |
| # ruby # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # FOR LOOP - SQL | |
| do $$ | |
| begin | |
| for r in 1..100000 loop | |
| insert into events(id,location_id, status) values(r,1,'ACTIVE'); | |
| end loop; | |
| end; | |
| $$; | |
| # LOOP INSERT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var activeEvents = yield new Model.Event() | |
| .query(function(qb) { | |
| qb.where('status', 'ACTIVE').orderBy('id', 'DESC').limit(5) | |
| }) | |
| .fetchAll({ | |
| withRelated: [ | |
| 'host', | |
| 'location.facilities', | |
| ] | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| var fs = require('fs'); | |
| var port = "8080" ; | |
| http.createServer(function(request, response) { | |
| response.writeHead(200, { | |
| 'Content-Type': 'text/json', | |
| 'Access-Control-Allow-Origin': '*', | |
| 'X-Powered-By':'nodejs' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.up = function(knex, Promise) { | |
| return renameProductsTable() | |
| .then(updateRecordsReferences) | |
| .then(updateSummariesReferences); | |
| function renameProductsTable() { | |
| return knex.schema.renameTable('products', 'finished_goods'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "ensure_newline_at_eof_on_save": false, | |
| "font_size": 11, | |
| "ignored_packages": | |
| [ | |
| "Vintage" | |
| ], | |
| "tab_size": 2, | |
| "translate_tabs_to_spaces": true, | |
| "trim_automatic_white_space": true, |