View routes.rb
admin_constraint = lambda do |request|
request.env['warden'].authenticate? and not request.env['warden'].user.nil?
end
constraints admin_constraint do
mount Logster::Web, at: "/logs"
end
View recursive_test.rb
@max_count = 5
def recursive_test(p1)
begin
if @max_count > 1
raise "test"
else
@max_count + p1
end
rescue
View create_snap_shots.rb
class CreateSnapShots < ActiveRecord::Migration[5.0]
def change
create_table :snap_shots do |t|
t.integer :user_id
t.string :table_name
t.text :table_data , limit: 4294967295
t.integer :table_id
t.integer :snapshot_id
t.timestamps
View gmail_sender.rb
require 'pony'
=begin
Use gmail's smtp server to send email:
1. Turn on 2-Step Verification (see https://myaccount.google.com/security)
2. Sign in using App Passwords (see https://support.google.com/accounts/answer/185833?hl=en)
or alternative method:
1. Turn off 2-Step Verification (see https://myaccount.google.com/security)
2. Allow less secure apps: https://myaccount.google.com/u/0/lesssecureapps?pli=1
View app.py
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route('/base/<path:filename>')
def base_static(filename):
return send_from_directory(app.root_path + '/../static/', filename)
View nginx-default-conf
vim `/etc/nginx/sites-available/default`
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name erlang.us;
View test-cssom.js
const css = require('css');
const crypto = require('crypto');
const assert = require('assert');
var style = `.foo {
color: green;
}
.bar {
color: red;
}
View Shadow-DOM.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Shadow DOM</title>
<style>
span {
color: green;
}
</style>
View kvs.erl
-module(kvs).
-behaviour(gen_server).
%% API
-export([start_link/0, store/2, lookup/1]).
%% gen_server callbacks
-export([init/1,
handle_call/3,
handle_cast/2,
View method_missing.erl
-module(method_missing).
-export(['$handle_undefined_function'/2]).
'$handle_undefined_function'(Func, Args) ->
io:format("Called undefined function '~p' with args ~p.~n", [Func, Args]).