Hi:
perl -e 'print "hello world!\n"'
A simple filter:
perl -ne 'print if /REGEX/'
Filter out blank lines (in place):
#!/usr/bin/env ruby | |
# | |
# This code snippet shows how to enable SSL in Sinatra+Thin. | |
# | |
require 'sinatra' | |
require 'thin' | |
class MyThinBackend < ::Thin::Backends::TcpServer | |
def initialize(host, port, options) |
Hi:
perl -e 'print "hello world!\n"'
A simple filter:
perl -ne 'print if /REGEX/'
Filter out blank lines (in place):
# -*- coding: utf-8 -*- | |
from bs4 import BeautifulSoup | |
import requests | |
username = '' ###账号### | |
password = '' ###密码### | |
login_url = 'http://v2ex.com/signin' ###如V2EX设置了使用 SSL,必须改 https### | |
index_url = 'http://v2ex.com' ###同上### | |
mission_url = 'http://www.v2ex.com/mission/daily' ###同上### | |
UA = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) \ |
[Unit] | |
Description=MongoDB Database Service | |
Wants=network.target | |
After=network.target | |
[Service] | |
Type=forking | |
PIDFile=/var/run/mongodb/mongod.pid | |
ExecStart=/usr/local/bin/mongod --config /etc/mongod.conf | |
ExecReload=/bin/kill -HUP $MAINPID |
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use PerlIO::gzip; | |
my $pattern = $ARGV[0]; | |
my $file = $ARGV[1]; | |
open my $z, '<:gzip', $file or die "gunzip failed: $!\n"; | |
while ( <$z> ) { | |
print if /$pattern/i; |
# This will return either JSON or JSONP depending on the existence of a callback. | |
def jsonp(request, dictionary): | |
if (request.query.callback): | |
return "%s(%s)" % (request.query.callback, dictionary) | |
return dictionary | |
@route('/something') | |
def something(): | |
return jsonp(dict(success="It worked")) |
There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.
From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?