Skip to content

Instantly share code, notes, and snippets.

Avatar

Oleksii Bobko oleksiiBobko

  • Vinnytsia
View GitHub Profile
@oleksiiBobko
oleksiiBobko / draw.py
Last active Oct 23, 2022
Capture CPU utilization per core
View draw.py
import psutil
import time
import matplotlib.pyplot as plt
def start():
cpu_cores = psutil.cpu_count()
time_range = [i for i in range(60)]
cores = []
View srvs.js
#!/usr/bin/env node
var fs = require("fs");
var http = require("https");
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
View cheatsheet
#remove all .orig files in a particular directory recursively
find . -name '*.orig' -delete
#rebase
git rebase -i HEAD~3
#undo commit and redo:
$ git commit -m "Something terribly misguided"
$ git reset HEAD~
#edit files as necessary
View srv.js
#!/usr/bin/env node
var http = require("http");
var server = http.createServer(function(request, response) {
console.log('-------------------------');
console.log(request.headers);
request.on('data', function(chunk) {
console.log("Received body data:");
console.log(chunk.toString());
View .vimrc
syntax on
set nu
color koehler
filetype plugin indent on
set tabstop=4
set shiftwidth=4
set expandtab
set listchars=eol:¶,tab:->,trail:~,extends:>,precedes:<,space:·
set list
@oleksiiBobko
oleksiiBobko / dfg.js
Created Jul 5, 2016
js closure example
View dfg.js
#!/usr/bin/env node
function celebrityIDCreator (theCelebrities) {
var i;
var uniqueID = 100;
for (i = 0; i < theCelebrities.length; i++) {
theCelebrities[i]["id"] = function (j) {
// the j parametric variable is the i passed in on invocation of this IIFE
return function () {
return uniqueID + j;
View App.java
package x.y.z;
import java.util.HashMap;
import java.util.Map;
/**
* Hello world!
*
*/
public class App {
@oleksiiBobko
oleksiiBobko / tcp_server.c
Last active Nov 24, 2022
Simple socket server in C using threads (pthread library) Compiles on linux
View tcp_server.c
/*
C socket server example, handles multiple clients using threads
Compile
gcc server.c -lpthread -o server
*/
#include<stdio.h>
#include<string.h> //strlen
#include<stdlib.h> //strlen
#include<sys/socket.h>