Skip to content

Instantly share code, notes, and snippets.

🏠
Coffee shop programmer 24h

Sirawat Pitaksarit 5argon

🏠
Coffee shop programmer 24h
Block or report user

Report or block 5argon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@5argon
5argon / SharpZibLibTest.cs
Last active Jun 12, 2017
Compress, decompress example/benchmark test.
View SharpZibLibTest.cs
using UnityEngine;
using System.Collections;
using System.IO;
using System;
using System.Diagnostics;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
using ICSharpCode.SharpZipLib.Core;
@5argon
5argon / GoogleDocsHighlighter.gs
Created May 22, 2017
Highlight a character name (5argon : Hello world!) or any lines that begin with # sign. Each character get different colors via the function at the bottom.
View GoogleDocsHighlighter.gs
/**
* @OnlyCurrentDoc
*
* The above comment directs Apps Script to limit the scope of file
* access for this add-on. It specifies that this add-on will only
* attempt to read or modify the files in which the add-on is used,
* and not all of the user's files. The authorization request message
* presented to users will reflect this limited scope.
*/
@5argon
5argon / GoogleDocsBoldAll.gs
Created May 22, 2017
Google Docs add-ons script to bold everything.
View GoogleDocsBoldAll.gs
/**
* @OnlyCurrentDoc
*
* The above comment directs Apps Script to limit the scope of file
* access for this add-on. It specifies that this add-on will only
* attempt to read or modify the files in which the add-on is used,
* and not all of the user’s files. The authorization request message
* presented to users will reflect this limited scope.
*/
@5argon
5argon / GoogleDocsFormatBasic.gs
Created May 22, 2017
How to format an entire document using RegEx in Google Docs add-on. It will bold my name in string like "5argon : Hello World!"
View GoogleDocsFormatBasic.gs
function formatInkVN() {
var body = DocumentApp.getActiveDocument().getBody();
//all text!
var allText = body.editAsText();
var regexString = "^.*[ ]:[ ]";
var rangeElement = allText.findText(regexString);
while (rangeElement != null) {
var matchedText = rangeElement.getElement().asText();
@5argon
5argon / srvport.sh
Last active Feb 20, 2017
Get an SRV record's port number + target from a URL. (OSX/Linux, or maybe Windows if you have grep) Separated by a whitespace.
View srvport.sh
URL=$1
nslookup -type=SRV $URL | grep -Eo "service.*" | grep -Eo "[0-9]*[ ][^ ]*$"
@5argon
5argon / randomBase32.sql
Last active Feb 17, 2017
Create a PostgreSQL function that generates a random a Base32 string. Note that it might not be compatible with 8-bit ASCII under certain length because it maps each 5 bits to one Base32 character, so multiples of 8 will work. (8 5-bit Base32 characters = 40-bit = 5 8-bit ASCII characters) (Adapted from : http://stackoverflow.com/questions/39707…
View randomBase32.sql
CREATE OR REPLACE FUNCTION yourschema.randomBase32(length integer)
RETURNS text AS $$
declare
chars text[] := '{2,3,4,5,6,7,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}';
result text := '';
i integer := 0;
begin
if length < 0 then
raise exception 'Given length cannot be less than 0';
end if;
@5argon
5argon / IntToStringLookup.cs
Last active Feb 8, 2017
Make int.ToString() faster to a certain number by changing it to int.ToStringLookup(). Avoiding dynamic memory allocation on the stack but uses more memory on the heap. Use the python program to generate a new lookup array.
View IntToStringLookup.cs
public static class IntToStringLookup {
/*
A Python program for you!
import sys
import math
k = 0
You can’t perform that action at this time.