Skip to content

Instantly share code, notes, and snippets.

@rightgo09
rightgo09 / time_parse.rs
Created May 5, 2022 01:32
Parse unixtime in Rust
use std::env;
use chrono::prelude::DateTime;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("argument is unixtime");
return;
}
class Hoge
def get_v
@@v ||= 123
end
class << self
def inc_v
@@v ||= 0
@@v += 1
end
@rightgo09
rightgo09 / install_java7.txt
Created December 31, 2013 14:29
Ubuntu 12.04 に Java7をインストールする
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer
$ unzip typesafe-activator-1.3.7-minimal.zip
$ mv ~/Downloads/activator-1.3.7-minimal ~/local
$ ln -s ~/local/activator-1.3.7-minimal/activator ~/bin/activator
$ chmod +x ~/local/activator-1.3.7-minimal/activator
$ mkdir play2.4.6_test
$ cd play2.4.6_test/
@rightgo09
rightgo09 / bench.txt
Created September 9, 2013 08:01
JSON vs Oj
$ ruby bench.rb
Rehearsal ----------------------------------------------------
encode with oj 14.880000 0.020000 14.900000 ( 14.900684)
encode with json 95.250000 0.020000 95.270000 ( 95.261347)
----------------------------------------- total: 110.170000sec
user system total real
encode with oj 15.220000 0.000000 15.220000 ( 15.229005)
encode with json 95.140000 0.060000 95.200000 ( 95.211977)
@rightgo09
rightgo09 / sinatra_multi_route.rb
Created August 29, 2013 14:09
Use sinatra-multi-route
require "sinatra"
require "sinatra/multi_route"
route :get, :post, "/" do
"hello"
end
set(:auth) do |role|
condition do
if role == :logged_in
#!/usr/bin/php
<?php
function is_palindrome($str) {
return $str == join('', array_reverse(str_split($str)));
}
foreach (array('level', 'hoge') as $str) {
if (is_palindrome($str)) {
echo "$str is palindrome!\n";
}
#!/bin/sh
rm /var/lib/dhcp/*
rm -f /etc/udev/rules.d/70-persistent-net.rules
rm -f /etc/resolv.conf
dd if=/dev/zero of=/EMPTY bs=1M
rm /EMPTY
vagrant@ubuntu1204:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.5.31-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
requires 'Getopt::Long';
requires 'PDF::API2';