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
#! /bin/bash | |
### BEGIN INIT INFO | |
# Provides: unicorn | |
# Required-Start: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the unicorn web server | |
# Description: starts unicorn |
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
# This file should be placed on the directory of ~/blog/config | |
upstream unicorn { | |
server unix:/tmp/unicorn.todo.socket fail_timeout=0; | |
} | |
server { | |
listen 80 default; | |
#server_name example.com; | |
root /home/username/blog/public; |
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
#No such file to load -- devise/confirmations_controller | |
#resque worker devise not eager loading | |
require File.expand_path('../config/application', __FILE__) | |
require 'rake/dsl_definition' | |
require 'resque/tasks' | |
Askjane::Application.load_tasks | |
task "resque:setup" => :environment do |
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' | |
redis = Redis.new | |
names = [] | |
keys = redis.keys("connect*:*") | |
if !keys.empty? | |
redis.del(*keys) | |
end |
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
# encoding: UTF-8 | |
namespace :db do | |
desc "get all of the notes from episodes table" | |
task :episodes => :environment do | |
def header(name) | |
str = <<-EOF.gsub(/^\s{6}/, '') | |
--- | |
layout: post | |
title: #{name} | |
--- |
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
# encoding: utf-8 | |
def html(num, sname, fname, token) | |
str = <<-EOF | |
<tr class="episode-wrap#{token}"> | |
<td class="episode-index">#{num}</td> | |
<td class="episode-title"> | |
<a href="#{fname}">#{sname}</a> | |
</td> | |
</tr> |
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
#!/usr/bin/env bash | |
on_die() { | |
echo+ | |
echo byebye proxy | |
echo+ | |
networksetup -setsocksfirewallproxystate "Ethernet 2" off #close the proxy+ | |
} |
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
# encoding: utf-8 | |
str = '' | |
File.open("tasks.md", 'r') do |f| | |
str = f.read | |
end | |
str = str.gsub(/^###\s?(.*?)\s?$/, "<h3>\\1</h3>\n"). | |
gsub(/^任务:\s?(.*?)\n$/, "<div>\n<h3>\\1</h3>\n<ul>"). | |
gsub(/^\-\s+视频:\s?(.*?)$/, "</ul>\n<a href='\\1'>视频</a>\n</div>\n"). |
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
// 1. How to check if one array has all elements of another? | |
var importedEmails = ['[email protected]', '[email protected]'], | |
existingEmails = ['[email protected]', '[email protected]', '[email protected]']; | |
if(!_.difference(importedEmails, existingEmails).length) console.log('already imported') | |
// > already imported | |
// ********************************************************** | |
// 2. How to find what elements are common to two arrays? |
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
# encoding: UTF-8 | |
namespace :db do | |
desc "import some data to the users table" | |
task :users => :environment do | |
a = [] | |
File.open("lib/tasks/talk_production.sql", 'r') do |f| | |
a = f.read.strip.split(/\n/) | |
end | |
a.delete_at(0) | |
a.each do |e| |
OlderNewer