忘れがちなものをメモ
tar 圧縮
tar -cvf file_B.tar dir_A
tar -cvzf file_B.tar.gz dir_A
スワップ 無効・有効切り替え(mac)
| #include <iostream> | |
| using namespace std; | |
| int main() | |
| { | |
| int sum = 0; | |
| for(int i = 1; i < 1000; i++){ | |
| if(i % 3 == 0 || | |
| i % 5 == 0) | |
| sum += i; |
| #include <iostream> | |
| using namespace std; | |
| int fib(int _n){ | |
| if(_n <= 0) | |
| return 0; | |
| else if(_n == 1) | |
| return 1; | |
| else if(_n == 2) | |
| return 2; |
| // This is pseudo code. | |
| size_t size; | |
| sysctlbyname("hw.machine", NULL, &size, NULL, 0); | |
| char *name = malloc(size); | |
| sysctlbyname("hw.machine", name, &size, NULL, 0); | |
| NSString *modelIdentifier = [NSString stringWithCString:name encoding:NSUTF8StringEncoding]; | |
| free(name); |
| #! /bin/bash | |
| # Ubuntu Provisioning Script | |
| # basic packages | |
| sudo apt-get update | |
| sudo apt-get install -y openssh-server git language-pack-ja libssl-dev libsqlite3-dev build-essential nginx python-software-properties memcached | |
| # install mysql | |
| # warning: change the password 'root' to something else. |
| #! /usr/bin/env python | |
| def fb(n): | |
| dic = {} | |
| for num in range(1, n+1): | |
| dic[num] = "" | |
| for num in range(3, n+1)[::3]: | |
| dic[num] += "Fizz" | |
| for num in range(5, n+1)[::5]: | |
| dic[num] += "Buzz" |
| #! /bin/bash | |
| # create 512MB RamDisk | |
| # (0.512(GB) * (1024^3)) / 512 | |
| rm -rf ~/Library/Caches | |
| diskutil erasevolume HFS+ 'RamDisk' `hdiutil attach -nomount ram://1073741` | |
| ln -s /Volumes/Ramdisk ~/Library/Caches |
| #! /usr/bin/env python | |
| import sys | |
| DEFAULT_INDENT = 4 | |
| def main(): | |
| argc = len(sys.argv) | |
| f = None # File IO |
| #!/bin/bash | |
| #Created and tested on Mac OS X only. | |
| brew tap phinze/cask | |
| brew install brew-cask | |
| brew cask install basictex | |
| if [[ $PATH =~ "texbin" ]]; then |
| #!/bin/bash | |
| #today's coding fragment | |
| string="path-to-something:$PATH" | |
| if [[ $PATH =~ "path-to-something" ]]; then | |
| echo "\$PATH contains it" | |
| fi |