Skip to content

Instantly share code, notes, and snippets.

View superscott's full-sized avatar
👺
щ(ಠ益ಠщ) (✖╭╮✖) ᕦ(ò_óˇ)ᕤ

superscott superscott

👺
щ(ಠ益ಠщ) (✖╭╮✖) ᕦ(ò_óˇ)ᕤ
View GitHub Profile
@superscott
superscott / Main.rb
Last active August 29, 2015 13:57
rails email validator?
class Main
validate :email_is_valid
def email_is_valid
vtools = Tools.new
unless vtools.email_valid?(self.email)
logger.error("Invalid Email Domain :: PID: #{$$} EmailDomain: '#{vtools.domain}' ::")
errors.add(:base, "Invalid Email Address.")
end
end
@superscott
superscott / pyrag.rb
Created March 7, 2014 22:41
shitty math
n1 = ARGV[0]
n2 = ARGV[1]
e1 = ARGV[2]
e2 = ARGV[3]
n = n1.to_f - n2.to_f
e = e1.to_f - e2.to_f
nn = n * n
ee = e * e
(function(b, k, l, h) {
var i = function(a, b) {
arguments.length && this._init(a, b)
}, j = 0;
i.prototype = {
defaults: {
mainClass: "pickList",
listContainerClass: "pickList_listContainer",
sourceListContainerClass: "pickList_sourceListContainer",
controlsContainerClass: "pickList_controlsContainer",
<div id="error_page" class="box">
<h1>Ops, 404</h1>
<p>
似乎没有这个页面哦!大哥,去看看别的吧。
</p>
</div>
<!--因为不排除连rails 都无法运行的情况 所以添加 'public/STATUS.htm' 还是很有必要的-->
<!--more>
Finally, the default exceptions application used by Rails that simply renders a page in `public/STATUS.html` is available here: [action_dispatch/middleware/public_exceptions.rb](https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/public_exceptions.rb)
Remember that whatever you do in the errors controller, it should not be anything “fancy”. Keep it simple because something already went wrong with your application!
@superscott
superscott / pi.rb
Last active January 4, 2016 01:59
pi / malloc / ubuntu
#
# ruby pi - how to calculate pi with ruby.
# proving that pi is the limit of this series:
# 4/1 - 4/3 + 4/5 - 4/7 + 4/9 ...
#
num = 4.0
pi = 0
plus = true
den = 1
@superscott
superscott / feeds.xml
Created December 16, 2013 01:45
RSS Notifier Feed List
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<opml version="1.0">
<head>RSS Notifier Subscriptions</head>
<body>
<outline htmlUrl="http://rubyrogues.com" title="Ruby Rogues" xmlUrl="http://rubyrogues.com/feed/" type="rss" text="Ruby Rogues"/>
<outline htmlUrl="http://packetstormsecurity.com/" title="Packet Storm" xmlUrl="http://rss.packetstormsecurity.com/" type="rss" text="Packet Storm"/>
<outline htmlUrl="http://slashdot.org/" title="Slashdot" xmlUrl="http://rss.slashdot.org/Slashdot/slashdot" type="rss" text="Slashdot"/>
<outline htmlUrl="http://www.exploit-db.com" title="Exploit-DB updates" xmlUrl="http://www.exploit-db.com/rss.xml" type="rss" text="Exploit-DB updates"/>
<outline htmlUrl="http://arstechnica.com" title="Ars Technica" xmlUrl="http://feeds.arstechnica.com/arstechnica/index" type="rss" text="Ars Technica"/>
<outline htmlUrl="http://podcasts.thoughtbot.com/giantrobots.xml" title="Giant Robots Smashing into other Giant Robots Pod
@superscott
superscott / ghost
Created December 15, 2013 23:22
Ghost init.d script
#! /bin/sh
### BEGIN INIT INFO
# Provides: ghost
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ghost Blogging Platform
# Description: Ghost: Just a blogging platform
### END INIT INFO
@superscott
superscott / config.js
Created December 15, 2013 23:12
Node.js / Ghost: config.js
// # Ghost Configuration
// Setup your Ghost install for various environments
var path = require('path'),
config;
config = {
// ### Development **(default)**
development: {
// The url to use when providing links to the site, E.g. in RSS and email.
@superscott
superscott / default
Created December 15, 2013 23:05
NGINX:: default - nginx.conf
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation