Skip to content

Instantly share code, notes, and snippets.

View MikimotoH's full-sized avatar

MikimotoH MikimotoH

View GitHub Profile
@MikimotoH
MikimotoH / copy_to_tsv.psql
Created May 10, 2022 05:07
PostgreSQL COPY TO TSV with header
copy sca_packages to '/var/lib/postgresql/sca_packages.tsv' CSV HEADER DELIMITER E'\t' NULL AS '';
@MikimotoH
MikimotoH / ssh_tar_download_exclude_directory.sh
Created August 16, 2019 04:21
ssh tar download exclude directory
ssh johndoe@192.168.99.99 "cd ~/project; tar --exclude='./downloads' -zcvf - ." | tar zxvf -
@MikimotoH
MikimotoH / centos6run_headless_browser_selenium_firefox.sh
Last active September 12, 2020 02:08
CentOS 6.6(final) run headless browser selenium and firefox
#!/bin/bash
# make CentOS 6.6 to run headless browser selenium
# Install Python Anaconda 3.4
# http://continuum.io/downloads
yum groupinstall "Development tools"
# https://gist.github.com/textarcana/5855427
# Follow these steps to set up a CentOS 6.3 host to run headless Selenium tests with Firefox.
sudo yum -y install firefox Xvfb libXfont Xorg
sudo yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
@MikimotoH
MikimotoH / build_vim_with_python2_python3.sh
Last active May 4, 2019 16:04
build vim with python2 python3 YouCompleteMe on Ubuntu 14.04
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-python3interp=yes \
--with-python3-config-dir=$(python3-config --configdir) \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=/usr/local
@MikimotoH
MikimotoH / Ubuntu_16.04_NVIDA_cuDNN_CNTK.md
Last active November 2, 2017 05:21
Build Deep Learning Environment on Ubuntu 16.04 (NVIDIA cuDNN and Microsoft CNTK)

Download Proprietary NVIDIA driver for "GeForce GTX 970"

wget NVIDIA-Linux-x86_64-384.90.run

disable nouveau driver

How to disable nouveau kernel driver on Ubuntu 16.04 [ https://askubuntu.com/a/868209/497162 ]

sudo vim /etc/modprobe.d/nvidia-graphics-drivers.conf
sudo vim  /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
sudo apt-get remove nvidia\*
sudo apt-get install dkms build-essential linux-headers-generic
@MikimotoH
MikimotoH / geoip.py
Created March 25, 2016 23:10
MaxMind "python-geoip" and "python-geoip-geolite2" in Python3.5 version, originally in "~/anaconda3/lib/python3.5/site-packages/geoip.py"
import sys
import mmap
import socket
import urllib.request, urllib.parse, urllib.error
from threading import Lock
from datetime import datetime
from struct import Struct
@MikimotoH
MikimotoH / regex_quoted_string_with_backslash_escaped.py
Created August 8, 2016 09:26
use regex to search double quoted string with backslash escaped double quote
In [40]: re.search(r'"(.*?)(?<!\\)"', r'"abc\" \"def" "ghi"')
Out[40]: <_sre.SRE_Match object; span=(0, 13), match='"abc\\" \\"def"'>
In [41]: print(_40.group(1))
abc\" \"def
@MikimotoH
MikimotoH / gist:6b1ed323ea29b87ad60d88be3084ef35
Created June 6, 2016 14:40
recover Ubuntu after unmount system disk
我的Ubuntu 14.04.3 LTS Desktop,我把左測的Files -> Devices 中的Ubuntu System disk給 unmount之後,從公司ssh連回家後發現做什麼都
disk i/o write error。
我強迫重開機後,進入黑白的GRUB command line,用了 set prefix=(hda2,2)/boot/grub ; insmod normal ; normal
也沒有效果。
使用 USB Boot Disk也沒有辦法修復。
我以為這裡面的data都毀了corrupted,救不回來了。
後來,我把ubuntu的SSD OCZ 240GB SSD 拆開到另一台電腦,用外接硬碟連接,另一台電腦用也用Ubuntu USB boot,沒想到發現外接SSD
裡面的資料完好如初。
後來,我把那/boot/grub/grub.cfg 中的ro都改成rw,再接回原來的電腦,沒想到就可以用了。
@MikimotoH
MikimotoH / caffe_pb2.py
Created April 17, 2016 12:18
CAFFE caffe_pb2.py for Python3, modified unicode("...","utf-8") to str("...")
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: caffe.proto
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
@MikimotoH
MikimotoH / Ubuntu_14.04_tty_is_black
Created January 25, 2016 14:13
Ubuntu 14.04.3 switching from desktop to tty (Ctrl-Alt-F1) the screen is black
Resolution:
http://askubuntu.com/questions/508635/how-can-i-get-ttys-to-work-with-nvidia-drivers?lq=1
fix grub resolution:
sudo nano /etc/default/grub
Now, locate the line
#GRUB_GFXMODE=640x480