Skip to content

Instantly share code, notes, and snippets.

View chrdek's full-sized avatar
♻️
Fully reCaptcha resistant....

ChrDek chrdek

♻️
Fully reCaptcha resistant....
  • Ham
  • Bacon
View GitHub Profile
@chrdek
chrdek / ssl-sample2.js
Created June 13, 2020 19:59
Login server with basic secure cookie authentication and json file as data store (log reqs).
var https = require('https');
var fs = require('fs');
var auth = require('basic-auth');
var cookie = require('cookie');
var signed = require('cookie-signature');
const csvconv = require('csvtojson');
const { parse } = require('json2csv');
const express = require('express');
const routing = express();
@chrdek
chrdek / client_connect.bat
Last active June 14, 2020 19:35
Client connection sample with https headers for self-signed cert.
curl -i https://localhost:443/loginconfig -1 -H "Cache-Control:no-cache" -H "Authorization:Basic cGFpcjAyOmRpY2ZlY2plZ2RqaGdmZWhqZmppYWNlZWFnYWNoYmFoYWNhaWo=" -H "Accept:*/*" -X GET --connect-timeout 3 -k
@chrdek
chrdek / scriptlets1.js
Created June 14, 2020 19:58
MongoDB cmd line sample code for bulk operations
/*** Get documents with specific name from collection ***/
db.getCollection('TableName1').find({Name:"Type1"})
/*** Get all documents from specific collection ***/
db.getCollection('TableName1').find({})
/*** Update one documemt field via upsert ***/
db.TableName1.update({Name:{$eq:"Type1"}},
{$set:{Id:"UPDATED1-1"}},
{upsert:true})
@chrdek
chrdek / Gen-Human-Read-Pass.ps1
Created August 15, 2020 02:39
Several methods to generate passwords with powershell
<# Methods for generating secure passwords with various types of security #>
# Password length 10, alphanumeric with symbols
$var = @("a","f","G","A","4""\","$","0","1","9","4","2",":F","3","..>","5","m","'","<",".","k","8","7","i",";","K","l","=","+"); $output="";
0..10 | %{ $output+=$var[$(Get-Random -Maximum 10)]; }
# Password length 10, SHA-256 derived OTP
(Get-Random) > "./tempcode.hash"; "$($((Get-FileHash -Path "./tempcode.hash").Hash)[0..10] + '')"-replace " ",([String]::Empty);
@chrdek
chrdek / gpioterm.sh
Last active August 15, 2020 17:24
Terminate process for pins from shell
#!/bin/bash
GPIO_PIN=10
# stop gpio pins, relevant cmd process
ctrl_c() {
echo "0" > "/sys/class/gpio/gpio${GPIO_PIN}/value"
echo $GPIO_PIN > /sys/class/gpio/unexport
exit
}
@chrdek
chrdek / DS0103EN-1-1-1-From-Problem-to-Approach-v2.0.ipynb
Created September 12, 2020 08:40
Created on Skills Network Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chrdek
chrdek / 12hr_to_24hr.js
Created October 12, 2020 17:54
Time Converter function (12Hr-24Hr format) using Javascript
// This oneliner function converts 12-Hour time into its 24-Hour counterpart.
// Examples (hh:mm:ss(PM/AM) to HH:MM:ss(24hour):
// 12:00PM ->12:00, 12:00AM->00:00, 04:00PM -> 16:00
function timeConversion(s) {
return (s.includes("PM")) ?
(s.replace(s.split(':')[0],(s.startsWith("12"))?s.split(':')[0]:(Number(s.split(':')[0])+12)+"")).replace("PM","") :
(s.replace(s.split(':')[0],
(s.startsWith("12"))?(s.split(':')[-1])||"00":s.split(':')[0])
.replace(s.split(':')[0],
@chrdek
chrdek / b64Enc_Dec.js
Created November 5, 2020 09:23
base64 encode, decode
//Extend the String object with toBase64() and fromBase64() functions
//ES6..
String.prototype.toBase64 = function() {
var basechars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
return [...this].map(c=>c.charCodeAt()).map(n=> {
return ((+n).toString(2).length < 8) ? "0".repeat(8-(+n).toString(2).length)+(+n).toString(2)
:(+n).toString(2);
}).join("")
.replace(/(\d)(?=(?:\d{6})+$)/g,"$1 ")
.split(" ")
@chrdek
chrdek / Modify_xls.ps1
Last active December 26, 2020 16:24
Add daily tasks in excel - with SIG (with DD/MM/YYYY)
Function Modify-Excel([switch]$addSheet) {
$defaultdir = "$env:USERPROFILE\Documents\Spreadsheet_1.xlsx";
$xls = New-Object -ComObject Excel.Application; $xls.Visible = $false;
$xlShiftDown = -4121;
$fileModify = $xls.Workbooks.Open($defaultdir);
# select latest/current working month ..
$spreadSheet = $fileModify.ActiveSheet; # $fileModify.Worksheets | ?{ $_.Name -ilike "*2020" } | Select -Last 1
@chrdek
chrdek / Wipe-Data.ps1
Last active January 3, 2021 13:07
Confidential files data wipe using various data shredding methods.
<#
.SYNOPSIS
** USE AT OWN RISK AND WITH CAUTION **
Function used for byte-level information scrambling for most files (For example: zip,documents,plain text or pdf).
.DESCRIPTION
** USE AT OWN RISK AND WITH CAUTION **
This function provides various methods of destroying the contents of a file, rendering it unreadable.
It can either be used on text or other types of data file formats.
Methods of removing data include XOR directly bytes in file, removing data by using source-dest. files