Skip to content

Instantly share code, notes, and snippets.

View srph's full-sized avatar
🛠️
Building @Stride-Labs Frontend

Kier Borromeo srph

🛠️
Building @Stride-Labs Frontend
View GitHub Profile
@srph
srph / 0rc.code-snippets
Last active May 30, 2024 19:18
React Component Snippet for VS Code (based on filename, with prop types)
{
"React Component": {
"prefix": "0rc",
"body": [
"import React from 'react';",
"",
"interface ${TM_FILENAME_BASE}Props {",
" name: string;",
"}",
"",
@srph
srph / stm.js
Last active April 25, 2024 17:54
js: standard time to military time
/**
* Standard Time to Military time
*
* @param {number} t Time to be converted
* @param {string} moridiem AM/PM
* @return {int}
*/
export default function stm (t, m) {
t = parseInt(t, 10);
@srph
srph / GenderInputSelect.jsx
Created April 2, 2016 13:19
react: gender input select
import React from 'react';
const GenderInputSelect = (props) =>
<select {...props}>
<option>Select gender</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
export default GenderInputSelect;
@srph
srph / parser.ts
Created November 25, 2022 17:27
Stride: stride.vesting.StridePeriodicVestingAccount
import { Pubkey } from '@cosmjs/amino'
import { Uint64 } from '@cosmjs/math'
import { decodePubkey } from '@cosmjs/proto-signing'
import { assert } from '@cosmjs/utils'
import { stride } from '@stride/proto'
import { BaseAccount, ModuleAccount } from 'cosmjs-types/cosmos/auth/v1beta1/auth'
import {
BaseVestingAccount,
ContinuousVestingAccount,
DelayedVestingAccount,
@srph
srph / DummyLink.jsx
Created March 31, 2016 23:33
react: dummy link (useful for non-link anchor elements / aka `href="#"`)
@srph
srph / web.php
Created November 2, 2016 00:07
Laravel - Catch all except /api routes. Useful for SPAs inside Laravel.
<?php
Route::get('{all}', function () {
return view('index');
})->where('all', '^((?!api).)*');
@srph
srph / DefaultPalWorldSettings.ini
Last active January 26, 2024 14:18
PalServer mid-rate config
; This configuration file is a sample of the default server settings.
; Changes to this file will NOT be reflected on the server.
; To change the server settings, modify Pal/Saved/Config/LinuxServer/PalWorldSettings.ini.
[/Script/Pal.PalGameWorldSettings]
OptionSettings=(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=0.500000,ExpRate=3.000000,PalCaptureRate=1.500000,PalSpawnNumRate=1.500000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=0.750000,PlayerAutoHPRegeneRate=2.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=0.750000,PalAutoHPRegeneRate=2.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=0.000000,CollectionDropRate=1.500000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.500000,EnemyDropItemRate=2.000000,DeathPenalty=None,
@srph
srph / ProductController.js
Last active January 16, 2024 14:13
Example for Writing Better AngularJS Apps https://medium.com/p/f2ab70a104d0/
// Our html would be,
// <product-search="productCtrl.filter"></product-table>
// <product-table="productCtrl.data"></product-table>
// Controller As productCtrl
angular
.module('app')
.controller('ProductController', ProductController);
function ProductController($scope, $http) {
@srph
srph / getStandardFormattedDateTime.ts
Created June 7, 2019 03:24
JS: mysql-formatted string with date-fns
import { format } from 'date-fns'
/**
* Gives you a mysql standard formatted datetime
* e.g., 2018-08-08 23:00:00
*/
function getStandardFormattedDateTime(date: Date = new Date()) {
return format(date, 'YYYY-MM-DD HH-mm-ss')
}
@srph
srph / throttle.manual.ts
Last active August 31, 2023 18:31
throttle: Guarantee an async functions only resolves after X ms
import { delay } from '../time'
import { throttle } from './throttle'
// @TODO: In the future, let's write some tests. It's proving to be challenging
// because vitest has no means of flushing promises, and it causes some tests
// to fail (ergo, we expect callback to resolve faster, but it doesn't).
//
// Manual test for throttle function. To run:
// $ npm i -g ts-node && ts-node throttle.manual.ts
const tests = {