Skip to content

Instantly share code, notes, and snippets.

View geekoff7's full-sized avatar
🎯
Focusing

geekoff7

🎯
Focusing
View GitHub Profile
@geekoff7
geekoff7 / Main.java
Last active October 5, 2018 06:16
ArrayToListAndListToArray
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
Integer[] array = new Integer[] { 1, 2, 3, 4 };
package main
import (
"fmt"
)
func main() {
var arr1 [2]string = [2]string{"A", "B"}
var slice1 = arr1[:]
slice1[0] = "a"
@geekoff7
geekoff7 / timeof.py
Created August 7, 2018 18:04
time elapsed command line program !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
import sys
from subprocess import call
cmd = sys.argv
t1 = time.perf_counter()
call(cmd[1:])
t2 = time.perf_counter()
@geekoff7
geekoff7 / color.txt
Last active August 7, 2018 07:46
code color
CODE COLOR
-----------------
[0;31m => Red
-----------------
[1;31m => Bold Red
-----------------
[0;32m => Green
-----------------
[1;32m => Bold Green
-----------------
@geekoff7
geekoff7 / fd_fp.c
Created August 1, 2018 06:56
file pointer and file descriptor in c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char const *argv[])
{
char str[] = "Hello World !!!";
int fd = fileno(stdout);
FILE *fp = fdopen(fd, "w");
fwrite(str, sizeof(char), sizeof(str), fp);
@geekoff7
geekoff7 / tor.cfg
Created July 31, 2018 15:03
tor config
# send email
# To : [email protected]
# Subject : empty
# Body : get transport obfs4
# torrc example file config
UseBridges 1
ClientTransportPlugin obfs4 exec /usr/bin/obfs4proxy
Bridge obfs4 IP:PORT HASH-OF-YOUR-OBFS4-BRIDGE
@geekoff7
geekoff7 / signal_handler.c
Created July 24, 2018 05:55
signal handler function in c program
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
volatile sig_atomic_t please_stop;
void handler_sigint()
{
@geekoff7
geekoff7 / const_char.txt
Created July 23, 2018 07:22
const char
char* is a mutable pointer to a mutable character/string.
const char* is a mutable pointer to an immutable character/string. You cannot change the contents of the location(s) this pointer points to. Also, compilers are required to give error messages when you try to do so. For the same reason, conversion from const char * to char* is deprecated.
char* const is an immutable pointer (it cannot point to any other location) but the contents of location at which it points are mutable.
const char* const is an immutable pointer to an immutable character/string.
@geekoff7
geekoff7 / libcpuid.sh
Last active July 22, 2018 15:10
compile libcpuid shell command
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
# in fish shell
echo (pkg-config libcpuid --cflags --libs) | xargs gcc main.c -o program
# in zsh or bash shell
gcc main.c -o program `pkg-config libcpuid --cflags`
export LD_LIBRARY_PATH=/usr/local/lib/
# run program
./program
@geekoff7
geekoff7 / main.c
Last active July 22, 2018 15:08
hygiene problem macro c programming language
#include <stdio.h>
#define MULTI(x) (x * 2)
int main() {
printf("%d \n", MULTI(3 + 3));
return 0;
}