Skip to content

Instantly share code, notes, and snippets.

window.getParameterByName = function(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) return "";
else return decodeURIComponent(results[1].replace(/\+/g, " "));
}
var capitalizeValue = function (value) {
market_source={
@pnghai
pnghai / conflict_bootstrap-datetimepicker_scss
Created April 12, 2018 08:24
Fix conflict of bootstrap-datetimepicker and bootstrap datepicker
.bootstrap-datetimepicker-widget {
.datepicker > div{
display: block;
}
}
@pnghai
pnghai / gist:9a2ffa72b9a42a48fdbbce366b3c4fcd
Last active September 27, 2021 12:43
Tron Address Generator with Ruby on Rails
require 'base58'
require 'digest'
require 'digest-sha3-patched-ruby-3'
def keccak256(data)
Digest::SHA3.digest(data, 256)
end
def verifying_key_to_addr(pub_key)
pub_key_bn = [pub_key].pack("H*")
@pnghai
pnghai / bashstyle.md
Created July 6, 2024 15:33 — forked from outro56/bashstyle.md
Bash scripting best practices (copied from https://github.com/progrium/bashstyle/blob/master/README.md)

progrium/bashstyle

Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:

  • It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
  • It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
  • It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.

This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne