Skip to content

Instantly share code, notes, and snippets.

View PeterOsinski's full-sized avatar
🎯
Focusing

Peter PeterOsinski

🎯
Focusing
View GitHub Profile
@PeterOsinski
PeterOsinski / index.js
Created November 8, 2020 17:21
MeiliSearcch - arXiv ingestion script in Node.js
const readline = require('readline');
const fs = require('fs');
const crypto = require('crypto');
const axios = require('axios');
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
@PeterOsinski
PeterOsinski / script.sql
Last active September 23, 2020 07:47
SQL Server snippets (SSS)
-- Source
-- https://www.sqlshack.com/gathering-sql-server-indexes-statistics-and-usage-information/
-- https://www.mssqltips.com/sqlservertutorial/256/discovering-unused-indexes/
-- https://www.mssqltips.com/sqlservertip/1239/how-to-get-index-usage-information-in-sql-server/
-- https://www.sqlshack.com/how-to-identify-and-monitor-unused-indexes-in-sql-server/
-- List indexes on a table
EXEC sp_helpindex '--table name here--'
-- Top 50 queries run on database
var config = require('../../config')
module.exports = function(req, res, next) {
if(config.debug){
res.header("Access-Control-Allow-Origin", 'http://localhost:8080');
res.header("Access-Control-Allow-Methods", "GET,POST,DELETE")
res.header("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With,Origin, Access-Control-Allow-Origin, x-access-token, Accept, x-pass")
res.header("Access-Control-Allow-Credentials", "true")
}
upstream app_crm {
zone app_crm 64k;
server 0.0.0.0:8001 max_fails=0 fail_timeout=10s weight=1;
server 0.0.0.0:8002 max_fails=0 fail_timeout=10s weight=1;
# server 0.0.0.0:8003 max_fails=0 fail_timeout=10s weight=1;
# server 0.0.0.0:8004 max_fails=0 fail_timeout=10s weight=1;
# Send visitors back to the same server each time.
#ip_hash;
@PeterOsinski
PeterOsinski / main.c
Created February 10, 2019 20:37
Send data to message queue over HTTP with ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
void setup(){
WiFi.begin("ssid", "password");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
@PeterOsinski
PeterOsinski / show-git-branch-in-bash-prompt
Created September 22, 2017 11:54 — forked from stuarteberg/show-git-branch-in-bash-prompt
Code for your .bashrc file. Show current git branch on bash shell prompt....with color! (This was copied and modified from similar code you can find out there on the 'tubes.)
# Colors for the prompt
blue="\033[0;34m"
white="\033[0;37m"
green="\033[0;32m"
# Brackets needed around non-printable characters in PS1
ps1_blue='\['"$blue"'\]'
ps1_green='\['"$green"'\]'
ps1_white='\['"$white"'\]'
var files = event.target.files || event.dataTransfer.files;
if (!files.length){
return;
}
var fd = new FormData
fd.append('file', files[0])
http.post('/api/admin/file/upload', fd)
@PeterOsinski
PeterOsinski / minify-js.sh
Created March 10, 2016 10:07 — forked from gurdiga/minify-js.sh
JS minifying script with curl and Closure Compiler REST API
#!/bin/sh
# Use like this:
#
# minify-js.sh < app.js > app.min.js
#
curl -s \
-d compilation_level=SIMPLE_OPTIMIZATIONS \
-d output_format=text \
function bindReady(handler){
var called = false
function ready() {
if (called) return
called = true
handler()
}
uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top