Skip to content

Instantly share code, notes, and snippets.

View ninovsnino's full-sized avatar

Nino Wicaksono ninovsnino

View GitHub Profile
@ninovsnino
ninovsnino / .vimrc
Created August 26, 2015 09:21
my vimrc settings+plugins
set encoding=utf-8
" set guifont=Monaco:h9
" set guifont=CamingoCode:h10
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h10:cANSI
set lines=50 columns=110
set go-=T
if has('gui_running')
set background=dark
else
set background=dark
@ninovsnino
ninovsnino / rsa_example.py
Created November 30, 2015 06:57
RSA key gen, encrypt/decrypt, and sign/verify with PyCrypto
# using pycrypto (2.3)
from Crypto.PublicKey import RSA
# generate(self, bits, randfunc=None, progress_func=None) method of Crypto.PublicKey.RSA.RSAImplementation instance
new_key = RSA.generate(bits=2048)
# exportKey(self, format='PEM') method of Crypto.PublicKey.RSA._RSAobj instance
# Export the RSA key. A string is returned
# with the encoded public or the private half
@ninovsnino
ninovsnino / pyopenssl_x509_signverify_example.py
Last active November 2, 2023 14:29
PyOpenSSL example of self sign X509 with RSA key-pair to do sign and verify
from OpenSSL import crypto
from socket import gethostname
k = crypto.PKey()
k.generate_key(crypto.TYPE_RSA, 2048) # generate RSA key-pair
cert = crypto.X509()
cert.get_subject().C = "<country>"
cert.get_subject().ST = "<city>"
@ninovsnino
ninovsnino / .vimrc
Last active May 29, 2016 03:36
vim load matchit and exclude directory in fuzzyfinder
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
let g:fuf_file_exclude = '\v\~$'
\ . '|\.(o|png|PNG|JPG|class|CLASS|jpg|exe|dll|bak|swp|pyc|pyo)$'
\ . '|(^|[/\\])\.(hg|git|bzr)($|[/\\])'
\ . '|(^|[/\\])venv[/\\]'
@ninovsnino
ninovsnino / getch_in_linux.c
Created June 14, 2016 23:12
Create yourself getch in linux using <termios.h> and <stdio.h>
#include <termios.h>
#include <stdio.h>
static struct termios old, new;
/* Initialize new terminal i/o settings */
void initTermios(int echo)
{
tcgetattr(0, &old); /* grab old terminal i/o settings */
new = old; /* make new settings same as old settings */
@ninovsnino
ninovsnino / 0_reuse_code.js
Created June 14, 2016 23:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ninovsnino
ninovsnino / ncurses_CMakeList.txt
Created June 14, 2016 23:56
CMake to link library, in this case is ncurses library
cmake_minimum_required(VERSION 2.8.9)
project (test_ncurses)
find_package(curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})
file(GLOB SOURCES "*.c")
add_executable(test_ncurses ${SOURCES})
@ninovsnino
ninovsnino / test_ncurses.c
Created June 15, 2016 00:02
Example of ncurses usage
#include <stdio.h>
#include <ncurses.h>
int main( void )
{
printf( "Hello Ncurses!\r\n" );
getch( );
return ( 0 );
}
@ninovsnino
ninovsnino / FizzBuzz.c
Created June 20, 2016 00:14
Fizz Buzz in C
#include <stdio.h>
int main( void )
{
int i;
for ( i = 1; i <= 100; i++ )
{
if ( !(i % 3) )
{
@ninovsnino
ninovsnino / c_set_and_clear_bit.c
Created March 10, 2017 00:43
bit set and clear example in c
#include "stdio.h"
#define ID_A 0x01
#define ID_B 0x02
int main() {
unsigned char type;
unsigned short result;
printf("size of unsigned char = %x\n", sizeof(unsigned char) );