Skip to content

Instantly share code, notes, and snippets.

View rastislavcore's full-sized avatar
⛓️
NuqneH, nuq?

Rastislav ₡ORE rastislavcore

⛓️
NuqneH, nuq?
View GitHub Profile
<?php
/**
* Translates a number to a short alhanumeric version
*
* Translated any number up to 9007199254740992
* to a shorter version in letters e.g.:
* 9007199254740989 --> PpQXn7COf
*
* specifiying the second argument true, it will
* translate back e.g.:
CREATE OR REPLACE FUNCTION string_to_bits(input_text TEXT)
RETURNS TEXT AS $$
DECLARE
output_text TEXT;
i INTEGER;
BEGIN
output_text := '';
FOR i IN 1..char_length(input_text) LOOP
/**
* Javascript AlphabeticID class
*
* Usage:
* var str = AlphabeticID.encode(9007199254740989); // str = 'fE2XnNGpF'
* var id = AlphabeticID.decode('fE2XnNGpF'); // id = 9007199254740989;
**/
var AlphabeticID = {
index:'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
class ShortId
{
public static readonly string Alphabet = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static decimal BcPow(double a, double b)
{
return Math.Floor((decimal)Math.Pow(a, b));
}
public static ulong Decode(string value, int pad = 0)
ALPHABET = "bcdfghjklmnpqrstvwxyz0123456789BCDFGHJKLMNPQRSTVWXYZ"
BASE = len(ALPHABET)
MAXLEN = 6
def encode_id(self, n):
pad = self.MAXLEN - 1
n = int(n + pow(self.BASE, pad))
s = []
@rastislavcore
rastislavcore / MacTerminalCommands.md
Created November 4, 2016 10:09
Cheatsheet for Mac terminal

SHORTCUTS

Key/Command Description
Ctrl + A Go to the beginning of the line you are currently typing on. This also works for most text input fields system wide. Netbeans being one exception
Ctrl + E Go to the end of the line you are currently typing on. This also works for most text input fields system wide. Netbeans being one exception
Ctrl + Q Clears everything on current line
Ctrl + L Clears the Screen
⌘Cmd + K Clears the Screen
Ctrl + U Cut everything backwards to beginning of line
@rastislavcore
rastislavcore / changecharset_latin1-utf8.sql
Created December 13, 2016 09:12
Correct garbled characters from Latin1 to UTF8
# Mysql: Convert encoding to UTF8 without garbled data
#1 Convert to blob then UTF8
ALTER TABLE comments MODIFY title BLOB;
ALTER TABLE comments MODIFY title VARCHAR(255) CHARACTER SET utf8;
#2 convert to BINARY then UTF8
-- test
SELECT CONVERT(CAST(CONVERT(title USING latin1) AS BINARY) USING utf8) FROM comments WHERE id = 123;
@rastislavcore
rastislavcore / transform_H-V_table.css
Created January 10, 2017 10:13
Transform horizontal to vertical table
table {
display:block;
padding: 0px;
border-collapse:collapse;
border-spacing:0;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
@rastislavcore
rastislavcore / batch_export_topng.jsx
Created April 14, 2017 10:42
Batch exporting to PNG from Adobe Illustrator
// Main Code [Execution of script begins here]
// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pngExportOpts;
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PNG', '~' );
@rastislavcore
rastislavcore / office_formats.txt
Last active May 5, 2021 19:47
Cryptocurrency format cells for LibreOffice
# Bitcoin
[$Ƀ-409]#,##0.00000000;-[$Ƀ-409]#,##0.00000000
# Ethereum
[$Ξ-409]#,##0.0000000000000000;-[$Ξ-409]#,##0.0000000000000000
# Core
[$₡-409]#,##0.0000000000000000;-[$₡-409]#,##0.0000000000000000