Skip to content

Instantly share code, notes, and snippets.

View phlegx's full-sized avatar
💪
never stop coding

Phlegx Systems phlegx

💪
never stop coding
View GitHub Profile
@vollnhals
vollnhals / pg_interval_rails_5_1.rb
Last active July 13, 2020 13:44
Implementation of interval database type in Rails 5.1
# implementation from https://github.com/rails/rails/pull/16919
# activerecord/lib/active_record/connection_adapters/postgresql/oid/interval.rb
require "active_support/duration"
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
@soulmachine
soulmachine / jwt-expiration.md
Last active April 10, 2025 12:28
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@przbadu
przbadu / _vue-rails.md
Last active July 16, 2022 21:48
Vue js and Rails integration

Setup Rails and Vuejs

  1. Generate new rails app using --webpack flag
rails new myApp --webpack=vue

Note:

  1. You can use --webpack=angular for angular application and --webpack=react for react.
@kripken
kripken / hello_world.c
Last active March 19, 2025 06:14
Standalone WebAssembly Example
int doubler(int x) {
return 2 * x;
}
@dvdbng
dvdbng / pg_dump
Created December 6, 2016 21:56
rails rake db:migrate pg_dump docker
#!/bin/bash
# rake db:migrate tries to connect to dump local postgres using pg_dump but
# you are using a docker instance? try saving this script as pg_dump somewhere
# in your PATH with higher priority
orig_params="$@"
volmount=""
while [[ $# -gt 1 ]]
do
@helgatheviking
helgatheviking / nav-menu-roles-toggle.php
Last active June 4, 2020 09:47
Give Nav Menu Roles priority over any competing Walkers
<?php
/*
Plugin Name: Nav Menu Roles Toggle
Plugin URI: https://gist.github.com/helgatheviking/d00f9c033a4b0aab0f69cf50d7dcd89c
Description: Give NMR priority over any competing Walkers
Version: 0.2.0
Author: helgatheviking
Author URI: http://kathyisawesome.com
*/
@bmweiner
bmweiner / sonos_airplay.md
Last active December 30, 2023 19:30
Stream audio to any Sonos component via AirPlay using a Raspberry Pi.

Sonos Airplay

Stream audio to any Sonos component via AirPlay using a Raspberry Pi (Model B, Raspbian Jessie) and the following software:

  • Shairport Sync: configures the Raspberry Pi as an AirPlay audio player.
  • DarkIce: encodes audio received from AirPlay (system audio) and sends it to Icecast2.
  • Icecast2: serves streaming audio from DarkIce at a network URL.
POST /oauth/token HTTP/1.1
Content-Type: application/json

{
  "grant_type": "password",
  "client_id": "CLIENT_ID",
  "owner_type": "OWNER_TYPE",
  "username": "OWNER_EMAIL",
 "password": "OWNER_PASSWORD"
@ashokmhrj
ashokmhrj / custom-template-plugin.php
Last active October 21, 2023 13:36
Get Template Part From plugin directory
<?php
/**
* The below function will help to load template file from plugin directory of wordpress
* Extracted from : http://wordpress.stackexchange.com/questions/94343/get-template-part-from-plugin
*/
define('PLUGIN_DIR_PATH','Your-plugin-directory-path');
function ccm_get_template_part($slug, $name = null) {
do_action("ccm_get_template_part_{$slug}", $slug, $name);
<?php
/**
* Plugin Name: Conditional WooCommerce Checkout Fields
* Description: Adds the abilitiy to conditionally show / hide checkout fields.
* Version: 1.0
* Author: Caleb Burks
* Author URI: http://calebburks.com
*/