This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// takes the form field value and returns true on valid number | |
function valid_credit_card(value) { | |
// accept only digits, dashes or spaces | |
if (/[^0-9-\s]+/.test(value)) return false; | |
// The Luhn Algorithm. It's so pretty. | |
var nCheck = 0, nDigit = 0, bEven = false; | |
value = value.replace(/\D/g, ""); | |
for (var n = value.length - 1; n >= 0; n--) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This method converts a Javascript object into | |
* a URI query string. Also handles nested arrays | |
* and objects (in Rails / PHP syntax) | |
* | |
* @author Sheharyar Naseer (@sheharyarn) | |
* @license MIT | |
* | |
* @example | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
## Returns a new flattened array | |
def custom_flatten | |
new_array = [] | |
# Recursively iterate over sub-arrays and other | |
# elements and concat them to the new array | |
self.each do |obj| | |
if obj.is_a?(Array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
#set -o xtrace | |
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")" | |
__base="$(basename ${__file} .sh)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testnet=1 | |
server=1 | |
# enable SSL for RPC server | |
#rpcssl=1 | |
rpcallowip=0.0.0.0/0 | |
rpcuser=admin | |
rpcpassword=123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Reddup Video Controls | |
// @version 0.1.0 | |
// @namespace https://www.reddup.co/ | |
// @homepageURL https://sheharyar.me/ | |
// @author Sheharyar Naseer | |
// @description Show Video Controls for all videos on Reddup | |
// @include http*://www.reddup.co/* | |
// @license MIT | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Flatten do | |
@doc """ | |
Flattens a List in Elixir | |
## Examples | |
``` | |
Flatten.flatten([1,2,3,4]) | |
# => [1,2,3,4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleJSON { | |
/** | |
* @author: Sheharyar Naseer (@sheharyarn) | |
* @license: MIT | |
*/ | |
public static Object toJSON(Object object) throws JSONException { | |
if (object instanceof HashMap) { | |
JSONObject json = new JSONObject(); | |
HashMap map = (HashMap) object; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* RVFragment - Fragment with a simple RecyclerView that | |
* only takes Strings | |
* | |
* Usage: | |
* RVFragment rvf = new RVFragment(); | |
* | |
* @author Sheharyar Naseer | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this file to "rails_app/lib/capistrano/tasks/nginx.rake" | |
# This will create these tasks: | |
# - cap stage nginx:start | |
# - cap stage nginx:stop | |
# - cap stage nginx:restart | |
# - cap stage nginx:reload | |
# Because of "sudo", you'll have to put nginx commands in your visudo file | |
# See this: https://gist.github.com/sheharyarn/f3d98e8cc859f092532b |