This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "encoding/binary" | |
| "math" | |
| ) | |
| import ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %matplotlib inline | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| class Point: | |
| def __init__(self, x, y): | |
| self.x = x | |
| self.y = y | |
| def desc(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import * | |
| from fractions import Fraction | |
| from sys import * | |
| def twice(x, y): | |
| x2 = (x*x*x*x-16*x)/(4*x*x*x+8) | |
| y2 = sqrt_frac(x2*x2*x2+2) | |
| return x2, y2 | |
| def sqrt_frac(x): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def isprime(n): | |
| if n == 2: | |
| return True | |
| if n == 3: | |
| return True | |
| if n % 2 == 0: | |
| return False | |
| if n % 3 == 0: | |
| return False | |
| i = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lsof |grep XXX|wc -l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <thread> | |
| #include <memory> | |
| #include <vector> | |
| #include <atomic> | |
| using namespace std; | |
| struct T { | |
| T(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <assert.h> | |
| int main(int argc, const char * argv[]) { | |
| FILE* fp = fopen("/tmp/a.log", "w"); | |
| for (int i = 0; i < 512; ++i){ | |
| FILE* dummp_fp = fopen("/tmp/a.out", "r"); | |
| if (dummp_fp == nullptr){ | |
| char buf[256]; | |
| sprintf(buf, "i[%d]\n", i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdlib> | |
| template <class T> | |
| struct MyAllocator { | |
| using value_type = T; | |
| // default constractor | |
| // copy constractor | |
| // move constractor | |
| MyAllocator() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if let stream:InputStream = InputStream(fileAtPath: "/Users/pebble8888/hoge.txt") { | |
| var buf:[UInt8] = [UInt8](repeating: 0, count: 16) | |
| stream.open() | |
| while true { | |
| let len = stream.read(&buf, maxLength: buf.count) | |
| print("len \(len)") | |
| for i in 0..<len { | |
| print(String(format:"%02x ", buf[i]), terminator: "") | |
| } | |
| if len < buf.count { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let a = try JSONSerialization.data(withJSONObject: ["alpha":["beta":"あいう", "gamma":"えおか"]], options: []) | |
| let b = try JSONSerialization.jsonObject(with: a, options: []) | |
| print("\(debugDescriptionUTF8(dic:b))") | |
| let c = try JSONSerialization.data(withJSONObject: ["alpha":["さしす", "せそた"]], options: []) | |
| let d = try JSONSerialization.jsonObject(with: c, options: []) | |
| print("\(debugDescriptionUTF8(dic:d))") | |
| func debugDescriptionUTF8(dic:Any) -> String { | |
| guard let dic = dic as? [String:Any] else { |