Skip to content

Instantly share code, notes, and snippets.

View bgadrian's full-sized avatar
✍️
available for OSS Go packages

B.G.Adrian bgadrian

✍️
available for OSS Go packages
View GitHub Profile
//JavaScript object
const myData={"id":1,"name":"Adrian","info":"My %website% is https://adrian.me"}
//Encode the data into JSON format, as a string
const asText=JSON.stringify(myData)
//encode the JSON string in Base64 for better transportation, like an envelope for a letter
//https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
const asBinary=window.btoa(asText)
//create an URL and encode it
const url=encodeURI("https://httpbin.org/get?user="+asBinary)
"the letters "a" and "b" (lowercase) in different character formats:
A_HTML_ENTITY="a"
A_ASCII_DECIMAL=97
B_HTML_ENTITY="b"
B_ASCII_DECIMAL=98
#the strings "a" and "b" encoded in base64
A_BASE64="YQ=="
B_BASE64="Yg=="
#"a" and "b" encrypted with the Blowfish algorithm (password "aaaa") in hexa
A_BLOWFISH="c2d15a8c28974fa4"
@bgadrian
bgadrian / install.sh
Last active October 20, 2017 13:58
Tutorial for GW windows
cd c: && \
wget -O "msys.7z" "https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/msys%2B7za%2Bwget%2Bsvn%2Bgit%2Bmercurial%2Bcvs-rev13.7z/download" --no-check-certificate && \
unzip msys.7z && \
mkdir c:\msys\mingw && \
echo "C:/MinGW-W64/mingw64 /mingw" >> "C:\msys\etc\fstab" && \
wget -O "C:\msys\bin\yasm.exe" "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe"
@bgadrian
bgadrian / 1.legacy.code.js
Last active October 13, 2017 20:19
Example for blog post: Constantly improving the codebase
var currentYear = 2017
//private function, fetch from DB
function getTodos() {
return [
{ name: "boogy", checked: true, year: 2014 },
{ name: "alfa", checked: false, year: 2017 },
{ name: "back to the future", checked: false, year: 2021 },
]
}
@bgadrian
bgadrian / hq.example.go
Created September 6, 2017 23:50
Go example for my hierarchical queue structure
package main
import (
"fmt"
"github.com/BTooLs/data-structures/priorityqueue"
)
func main() {
autoLockMutex := false
var lowestPriority uint8 = 10 //highest is 0
@bgadrian
bgadrian / vscode.extenstions.sh
Last active November 6, 2017 10:26
VisualStudioCode User Settings personal use
code --list-extensions
bierner.markdown-preview-github-styles
codezombiech.gitignore
dbaeumer.vscode-eslint
dimasalmaz.unity3d-pack
donjayamanne.javadebugger
hnw.vscode-auto-open-markdown-preview
jorgeserrano.vscode-csharp-snippets
k--kato.docomment
k--kato.intellij-idea-keybindings
@bgadrian
bgadrian / algorithm.interpolation.search.cs
Last active August 18, 2017 12:07
Interpolation search (binary search upgraded)
using System;
namespace interpolation
{
class Program
{
//usage: dotnet run 1 2 3 4 7 10 13
static void Main(string[] args)
{
//pseudocode https://www.tutorialspoint.com/data_structures_algorithms/interpolation_search_algorithm.htm
@bgadrian
bgadrian / count.smaller.js
Created August 15, 2017 20:06
Count the number of smaller numbers from my right (array)
//given an array arr, you have to return the amount of numbers that are smaller than arr[i] to the right.
// BSTree, complexity O(n squared)
var smaller = function (nums) {
var res = [], count = 0, i = nums.length - 2,thisCount = 0;
if (nums == null || nums.length == 0) return res;
var root = NewTreeNode(nums[nums.length - 1]);
res.push(0);
for (; i >= 0; i--) {
res.push(insertNodeAndCount(root, nums[i]));
@bgadrian
bgadrian / copy.structure.sh
Created May 19, 2017 21:04
Copy/rebuild a folder structure
#go to source
find . -type d -print0 > dirs.txt
#go to destination
xargs -0 mkdir -p < dirs.txt
@bgadrian
bgadrian / example.scss
Last active May 17, 2017 11:52
React-pagination integration with bootstrap button classes
//paths for meteor and node
@import "../../../node_modules/bootstrap/scss/mixins";
@import "../../../node_modules/bootstrap/scss/utilities";
@import "../../../node_modules/bootstrap/scss/buttons";
//example screenshot https://twitter.com/B3aT/status/864809895249555458
//I wanted the Active button to be bigger, but the react-pagination doesn't externalize the
//active - Link property, so this is a css workaround
//also it makes a fade-out for non-clickable elements