This file contains 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
const { promisify } = require('util'); | |
const sleep = promisify(setTimeout); | |
async function bar(n, s, t) { | |
setImmediate(() => process.stdout.write(s)); | |
await sleep(n); | |
return t; | |
} | |
async function foo() { |
This file contains 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
# config.ru | |
class SimpleApp | |
def self.call(env) | |
request = Rack::Request.new(env) | |
case request.path_info | |
when '/' | |
latency = Random.rand(0.05..5) | |
p "I'm lazy, my laziness is #{latency} seconds..." | |
sleep(latency) | |
[200, {"content-type" => "text/plain"}, ["Hello, World! Server latency is #{latency} s"]] |
This file contains 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 'redis' | |
module RedisStore | |
EXPIRATION_TIME_SECONDS = 1 * 24 * 60 * 60 # 1 day | |
def redis | |
@redis ||= Redis.new(host: 'localhost', port: 6379) | |
end | |
def set_cache(id, val) |
This file contains 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
scope :with_scope, -> { where(id: ARRAY_COLLECTION.map(&:id)) } |
This file contains 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
def render | |
pdf = Prawn::Document | |
pdf.image StringIO.new(Base64.decode64(splitBase64(BASE64_IMAGE_GOES_HERE)[:data])), at: [10, cursor - 50], width: 200, height: 125 | |
end | |
def splitBase64(uri) | |
if uri.match(%r{^data:(.*?);(.*?),(.*)$}) | |
return { | |
type: $1, # "image/png" | |
encoder: $2, # "base64" |
This file contains 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
@import url("https://fonts.googleapis.com/css?family=Open+Sans"); | |
body { font-family: 'Iowan Old Style', serif; background-color: rgb(94, 133, 172); line-height: 1.6; font-size: 17px; color: rgb(79, 50, 28); text-rendering: optimizelegibility; } | |
h1, h2 { font-family: 'Iowan Old Style', sans-serif; font-weight: 700; } | |
* { box-sizing: border-box; } | |
body { font-family: 'Iowan Old Style', sans-serif; font-style: normal; font-variant: normal; font-weight: 400; line-height: 1.85em; font-size: 18px; background-color: rgb(230, 218, 201); color: rgb(79, 50, 28); } | |
code { color: #ccc; background-color: rgb(34, 34, 34); } | |
pre code { background-color: transparent; } | |
pre { background-color: rgb(85, 85, 85); padding: 15px; } | |
.simple-container { max-width: 950px; margin: 0px auto; padding-top: 70px; padding-bottom: 20px; padding-left: 25px; padding-right: 25px; box-shadow: 0px 6px 12px 3px #555; background-color: rgb(248, 241, 227); } | |
p { color:rgb(79, 50, 28); font-size: 16px; } |
This file contains 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
@import url("https://fonts.googleapis.com/css?family=Open+Sans"); | |
body { font-family: 'Open Sans', serif; background-color: rgb(94, 133, 172); line-height: 1.6; font-size: 17px; color: rgb(255, 240, 240); text-rendering: optimizelegibility; } | |
h1, h2 { font-family: "Source Sans Pro", sans-serif; font-weight: 700; } | |
* { | |
-webkit-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
body { | |
font-family: 'Open Sans', serif; |
This file contains 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
One options: | |
$ git config --global alias.grog 'log --graph --abbrev-commit --decorate --all | |
--format=format:"%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(dim white) - %an%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n %C(white)%s%C(reset)"' | |
Second One: | |
$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit" |
This file contains 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
function AutoCompleteEditor(args) { | |
var $input; | |
var defaultValue; | |
var scope = this; | |
var calendarOpen = false; | |
this.init = function () { | |
$input = $("<INPUT type=text class='editor-text' />"); | |
$input.appendTo(args.container); |
This file contains 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
// Create /app/assets/javascripts/ckeditor/config.js file: | |
CKEDITOR.editorConfig = function( config ) | |
{ | |
config.toolbar = 'MyToolbar'; | |
config.toolbar_MyToolbar = | |
[ | |
{ name: 'document', items : [ 'NewPage','Preview' ] }, | |
{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] }, |
NewerOlder