Skip to content

Instantly share code, notes, and snippets.

View asidpulse's full-sized avatar

asidpulse asidpulse

  • Monroe, LA
View GitHub Profile
@ceving
ceving / Web Component for Copyright Years.md
Last active April 21, 2024 09:46
Web Component for Copyright Years
@tangentstorm
tangentstorm / sh.mjs
Last active April 21, 2024 12:16
shorthand javascript
// sh.mjs: javascript shorthand
// array helpers (apl/j/k)
export const id=x=>x
export const af=(n,x)=>Array(n).fill(x) // TODO: make this 'afl' or 'fil' (aa?)
export const ii=(n,f)=>{for(let i=0;i<n;i++)f(i)}
export const im=(n,f)=>af(n,0).map((_,i)=>f(i))
export const ia=(n,f)=>im(n,id)
export const at=(a,ixs)=>ixs.map(i=>a[i])
export const io=(xs,ys)=>ys.map([].indexOf.bind(xs))
@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
// 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
<?php
if(isset($_POST['login'])) {
if(!isset($_POST['g-recaptcha-response']) || empty($_POST['g-recaptcha-response'])) {
echo 'reCAPTHCA verification failed, please try again.';
} else {
$secret = 'google_secret_key';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@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) {
//
//
///////////////////////////////////////////////////////////////////////
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";
@sakalauskas
sakalauskas / FontAwesome-v5.0.9-Free.json
Last active February 14, 2024 03:28
List of all Font Awesome 5 icons in JSON Cheetsheet
{
"fas fa-address-book","fas fa-address-card","fas fa-adjust","fas fa-align-center","fas fa-align-justify","fas fa-align-left","fas fa-align-right","fas fa-allergies","fas fa-ambulance","fas fa-american-sign-language-interpreting","fas fa-anchor","fas fa-angle-double-down","fas fa-angle-double-left","fas fa-angle-double-right","fas fa-angle-double-up","fas fa-angle-down","fas fa-angle-left","fas fa-angle-right","fas fa-angle-up","fas fa-archive","fas fa-arrow-alt-circle-down","fas fa-arrow-alt-circle-left","fas fa-arrow-alt-circle-right","fas fa-arrow-alt-circle-up","fas fa-arrow-circle-down","fas fa-arrow-circle-left","fas fa-arrow-circle-right","fas fa-arrow-circle-up","fas fa-arrow-down","fas fa-arrow-left","fas fa-arrow-right","fas fa-arrow-up","fas fa-arrows-alt","fas fa-arrows-alt-h","fas fa-arrows-alt-v","fas fa-assistive-listening-systems","fas fa-asterisk","fas fa-at","fas fa-audio-description","fas fa-backward","fas fa-balance-scale","fas fa-ban","fas fa-band-aid","fas fa-barcode","fas fa-bars",
@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');
@RadGH
RadGH / short-number-format.php
Last active April 9, 2024 11:28
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {