This file contains 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
MAT_SIZE = 3 | |
mat = [[0 for i in range(MAT_SIZE)] for j in range(MAT_SIZE)] | |
# >>> mat | |
# [[0, 0, 0], [0, 0, 0], [0, 0, 0]] | |
for i, j in [(i, j) for i in range(MAT_SIZE) for j in range(MAT_SIZE)]: | |
mat[i][j] = 10*i + j | |
# >>> mat |
This file contains 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
mat = [[11,12,13],[21,22,23],[31,32,33]] | |
vec = [mat[i][j] for i, j in [(i, j) for i in range(len(mat)) for j in range(len(mat[0]))]] |
This file contains 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
nums = [1, 1.0, complex(1, 1)] | |
for num in nums: | |
print(isinstance(num, (int, float, complex))) | |
# True | |
# True | |
# True | |
print(isinstance(nums, list)) | |
# True |
This file contains 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 collections import namedtuple | |
Point = namedtuple('Point3d', 'x y z') | |
point = Point(10,20,30) | |
>>> point | |
Point3d(x=10, y=20, z=30) | |
>>> print point.x, point.y, point.z | |
10 20 30 | |
>>> print point[0], point[1], point[2] |
This file contains 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> | |
using namespace std; | |
int main() { | |
// your code goes here | |
for(int cnt ; true ; cnt++){ | |
if (cnt % 10 == 0) continue; | |
cout<<cnt<<endl; | |
if (cnt > 100) break; | |
} |
This file contains 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 <stdio.h> | |
#include <conio.h> | |
#include <string.h> | |
// プロトタイプ宣言 | |
void swap1(int x, int y); | |
void swap2(int* x, int* y); | |
void swap3(int& x, int& y); |
This file contains 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
var Q = require('q'), | |
defered = Q.defer(), | |
promise = defered.promise; | |
function heavyProcess(defered){ | |
setTimeout(function(){ | |
console.log('finish!') | |
defered.resolve('end') | |
}, 5000); | |
} |
This file contains 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
function makeSameDayArr(targetDay, firstDate){ | |
var targetDates = [], | |
targetDate = new Date(firstDate.getFullYear(), | |
firstDate.getMonth(), | |
1.0 + (7-(firstDate.getDay()-targetDay)%7)%7); | |
for(;targetDate.getMonth() == firstDate.getMonth();targetDate.setDate(targetDate.getDate()+7)){ | |
targetDates.push(new Date(targetDate)); | |
} | |
return targetDates; |
This file contains 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
range.getValues().forEach(function(arr, idx, mat){ | |
if(arr[0] == ''){ | |
range.splice(idx); | |
} else { | |
retNameDict[arr[0]] = {name: arr[1], mailAddress: arr[2]}; | |
} | |
}); |
This file contains 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
#!/bin/bash | |
sudo rm /etc/hosts | |
sudo cp /etc/hosts.normal /etc/hosts | |
rm ~/.bashrc | |
cp ~/.bashrc.normal ~/.bashrc | |
source ~/.bashrc |
OlderNewer