Skip to content

Instantly share code, notes, and snippets.

View anon5r's full-sized avatar
🏠
Working from home

anon anon5r

🏠
Working from home
View GitHub Profile
@anon5r
anon5r / progressbar.js
Last active August 16, 2019 22:18
コマンドラインでの進捗状況(プログレスバー)を表示するやつ(Node.JS)
// Pad string to right
String.prototype.pad=function(len,str){
if(typeof str=="undefined") str=" ";
if(this.length>len) return this.toString();
str=str.repeat(len-this.length);
return (this+str).substr(0,len);
}
// Pad string to left
String.prototype.lpad=function(len,str){
if(typeof str=="undefined") str=" ";
@anon5r
anon5r / progressbar.php
Last active August 16, 2019 22:18
コマンドラインでの進捗状況(プログレスバー)を表示する(PHP)
<?php
// 回転するやつ /-\|
$c=['|','/','-','\\'];
// like GCP
//$c=['⣤','⣆','⡇','⠏','⠛','⠹','⢸','⣰'];
$ci = count($c);
for($i=0;$i<=100;$i++){
echo "\r"; // 描画カーソルを行頭に戻す
$block=str_repeat('#',floor($i/5));
printf('Processing... %s [%-20s]%3d%%', $c[$i%$ci], $block, $i);
@anon5r
anon5r / string_pad.js
Last active April 11, 2016 05:14
Padding string fixed length
// Pad string to right
String.prototype.pad=function(len,str){
if(typeof str=="undefined") str=" ";
if(this.length>len) return this.toString();
str=str.repeat(len-this.length);
return (this+str).substr(0,len);
}
// Pad string to left
String.prototype.lpad=function(len,str){
if(typeof str=="undefined") str=" ";
@anon5r
anon5r / 山手線駅名名字.txt
Created April 6, 2016 09:53
JR山手線の駅名と同じあるいは類似する日本人の実在する名字
池袋
大塚
巣鴨
駒込
田端
日暮
上野
秋葉
神田
東京
@anon5r
anon5r / gitlab-psql.sh
Created March 25, 2016 01:30
To control PostgreSQL with SQL queries in GitLab omnibus docker image
#!/bin/sh
#sudo docker exec -it gitlab /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -U gitlab -d gitlabhq_production
sudo docker exec -it gitlab sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d gitlabhq_production
psql
<?php
/**
* 前方一致
* $haystackが$needleから始まるか判定します。
* @param string $haystack
* @param string $needle
* @return boolean
*/
function startsWith($haystack, $needle)
{
@anon5r
anon5r / autodiscover.xml
Created January 20, 2016 08:37
Auto email configure for Google App for Business
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<Protocol>
<Type>IMAP</Type>
<Server>imap.gmail.com</Server>
@anon5r
anon5r / nginx__site-availables__example.com.conf
Last active January 20, 2016 02:44
Let's EncryptでSSL対応+HTTP2対応したときの設定
server {
listen 443 ssl http2;
server_name example.com;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log main;
root /var/www/example.com/public;
index index.html;
@anon5r
anon5r / ssl_common.conf
Created January 20, 2016 02:29
SNI対応nginxでのSSL対応サイト共通設定ファイル
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_dhparam dhparam.pem;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header Cache-Control "public, must-revalidate";
## TLS Session Tickets setting
ssl_session_tickets off; # Requires nginx >= 1.5.9
ssl_session_ticket_key ssl_session_ticket.key;
@anon5r
anon5r / egosearch_app.js
Last active May 24, 2018 13:36
node.js+pushbulletによるエゴサーチ(改)
var keyword = /(?:正規表現|頑張(?:って|る)|書(?:いてみよ|こ)う)/
var device = '<user@example.com>';
var screen_name = 'your_screen_name';
var PushBullet = require('pushbullet');
var pusher = new PushBullet('PUSH_BULLET_API_KEY');
var twitter = require('ntwitter');
var twit = new twitter({
consumer_key: 'YOUR_CONSUMER_KEY',
consumer_secret: 'YOUR_CONSUMER_SECRET',
access_token_key: 'ACCESS_TOKEN_KEY',