Skip to content

Instantly share code, notes, and snippets.

View chiro-hiro's full-sized avatar
🤖
Bleep bloop, I am a robot. Eh, just kidding.

Chiro Hiro chiro-hiro

🤖
Bleep bloop, I am a robot. Eh, just kidding.
View GitHub Profile
@chiro-hiro
chiro-hiro / golang-tls.md
Created August 24, 2018 03:50 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@chiro-hiro
chiro-hiro / node-js-scan-files.md
Created January 3, 2019 04:00
NodeJS -- Scan all files for given path

This function will return an array of files for given path:

function scanDir(scanPath, filelist) {
  var filelist = filelist || [];
  var dirs = fs.readdirSync(scanPath);
  for (var i = 0; i < dirs.length; i++) {
    var _childPath = path.resolve(scanPath, dirs[i])
    if (fs.statSync(_childPath).isDirectory()) {
      scanDir(_childPath, filelist);
 } else {
@chiro-hiro
chiro-hiro / keybase.md
Created September 13, 2019 09:53
keybase.md

Keybase proof

I hereby claim:

  • I am chiro-hiro on github.
  • I am chiro8x (https://keybase.io/chiro8x) on keybase.
  • I have a public key ASCmwC369mu7TJyx0a_QmNetM1A56DLANYB9Q0gQeuFr8wo

To claim this, I am signing this object:

// Human constructor
function Human(name) {
this.name = name;
}
// Define name as a property
Object.defineProperty(Human.prototype, 'name', {
set: function (value) {
if (typeof value !== 'string') {
throw new TypeError('Name value was not a string');
class Human {
constructor(name) {
this.name = name;
this.race = 'Terran';
}
set name(value) {
if (typeof value !== 'string') {
throw new TypeError('Name value was not a string');
class Foo {
constructor() {
this.constructedAt = (new Date()).toDateString();
}
static getInstance() {
this.foo = 1;
this.instance = this;
return this.instance;
}
getValue() {
class Foo {
constructor() {
this.constructedAt = (new Date()).toISOString();
}
static getInstance() {
if (typeof this.instance === 'undefined') {
this.instance = new Foo();
}
return this.instance;
}
@chiro-hiro
chiro-hiro / submatrix.c
Created April 14, 2020 02:34
Find submatrix
#include <stdio.h>
#include <stdlib.h>
//Malloc a matrix
int **malloc_matrix(size_t rows, size_t cols)
{
int **data_pointer = (int **)malloc(sizeof(int *) * rows);
for (int i = 0; i < rows; i++)
{
data_pointer[i] = malloc(sizeof(int) * cols);
@chiro-hiro
chiro-hiro / blind-sql-injection.js
Created April 14, 2020 02:47
Blind SQL injection
const http = require('http');
function request(json) {
return new Promise((resolve, reject) => {
let startTime = Date.now();
let body = JSON.stringify(json);
const options = {
host: 'localhost',
method: 'POST',
port: 3000,
@chiro-hiro
chiro-hiro / singleton.ts
Created April 14, 2020 04:27
Singleton in TypeScript
const instanceMap: {[key:string]: any} = {};
export function Singleton<T>(instanceName:string, InstanceConstructor: new () => T):T {
if (typeof instanceMap[instanceName] === 'undefined') {
instanceMap[instanceName] = new InstanceConstructor();
}
return <T>instanceMap[instanceName];
}
export default Singleton;