Skip to content

Instantly share code, notes, and snippets.

View asidpulse's full-sized avatar

asidpulse asidpulse

  • Monroe, LA
View GitHub Profile
@travishoglund
travishoglund / Dreamweaver Tip
Created September 11, 2013 03:51
Remove Blank Lines Dreamweaver
Open the file
Click CTRL + F
Select "Current document" in "Find in" (You can also select the folder if you have multiple files)
Search in "Source code"
Tick "Use regular expression"
Type "[\r\n]{2,}" (without quotes) in "Find"
Type "\n" (without quotes) in "Replace"
Press "Replace All"
//This removes all blank lines in Dreamweaver.
public class FirebasePlayerMatchMaker {
public static interface OnMatchMadeCallback {
public void run(FirebasePlayerMatchMaker c);
}
public static final String RANDOM_ROOM_ID = "/Globl";
public static final String ROOM_ID = "/GameRooms";
public static final String GAMES_RECORD = "/OpenGameMoves";
@yoavniran
yoavniran / simple-nodejs-iv-encrypt-decrypt.js
Last active January 20, 2022 08:16
nodejs crypto - simple encrypt & decrypt using IV (Initialization Vector)
"use strict";
var crypto = require("crypto");
var EncryptionHelper = (function () {
function getKeyAndIV(key, callback) {
crypto.pseudoRandomBytes(16, function (err, ivBuffer) {
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ;
@jeffhuangtw
jeffhuangtw / sample.js
Created March 15, 2017 09:52
[nodejs] server side check "androidpublisher.purchases.subscriptions.get" with "service account"
// Google Play API Key
// ref: http://stackoverflow.com/questions/35127086/android-inapp-purchase-receipt-validation-google-play
// ref: https://developers.google.com/android-publisher/authorization
// ref: http://google.github.io/google-api-nodejs-client/18.0.0/index.html#toc14__anchor
//
// install npm package
// ref: https://github.com/google/google-api-nodejs-client
// $ npm install googleapis --save
//
const google = require('googleapis');
// time and time end
console.time("This");
let total = 0;
for (let j = 0; j < 10000; j++) {
total += j
}
console.log("Result", total);
console.timeEnd("This");
// Memory
// number to string, pluginized from http://stackoverflow.com/questions/5529934/javascript-numbers-to-words
window.num2str = function (num) {
return window.num2str.convert(num);
}
window.num2str.ones=['','one','two','three','four','five','six','seven','eight','nine'];
window.num2str.tens=['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety'];
window.num2str.teens=['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen'];
@gudbergur
gudbergur / gist:1426081
Created December 3, 2011 04:50
Very bare Embed.ly plugin for TinyMCE
// Requirements: jQuery
// Installation: Add this to your tinyMCE.init, put in your button image and your Embed.ly key and you're good to go
// This is just a very simple embed.ly button cause Google turned up squat.
setup : function(ed) {
ed.addButton('myembedly', {
title : 'Embed.ly',
image : 'BUTTON IMAGE',
onclick : function() {
var url = prompt("Enter URL to embed");
if (url == null) return;
@4cm
4cm / [php] datetime_IsUnixTimeStampValid
Created July 6, 2019 10:13
Validate if a Unix timestamp is valid.
/**
* Validate if a Unix timestamp is valid.
*
* @param $unixtimestamp
* @return bool
*/
function datetime_IsUnixTimeStampValid($unixtimestamp) {
//
//
///////////////////////////////////////////////////////////////////////
@Aslam97
Aslam97 / generate-referral-code.php
Created April 25, 2021 20:49
Generate referral code
<?php
use Illuminate\Support\Str;
function generateReferralCode($str) {
// get random number min & max 4 digit
$randomNumber = rand(1000, 9999);
// get the first 4 character and trim whitespace
$strName = trim(substr($str, 0, 4));
// get str length
@erans
erans / encrypt_decrypt_example.js
Last active October 14, 2022 02:31
Example of encryption and decryption in node.js
var crypto = require("crypto")
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(data, 'utf-8', 'hex');
crypted += cipher.final('hex');
return crypted;
}