Skip to content

Instantly share code, notes, and snippets.

View andreiglingeanu's full-sized avatar

Andrei Glingeanu andreiglingeanu

View GitHub Profile
@jlblancoc
jlblancoc / Install_gcc7_ubuntu_16.04.md
Last active October 10, 2023 03:09
Installing gcc-7 & g++-7 in Ubuntu 16.04LTS Xenial

Run the following in the terminal:

Install the gcc-7 packages:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y

Set it up so the symbolic links gcc, g++ point to the newer version:

@trueadm
trueadm / adopt-syntax.js
Last active November 27, 2021 03:32
Adding a the "adopt" keyword to the JSX syntax
// I'm suggesting we add a new "adopt X from <Y />" syntax to the JSX language
// it would de-sugar to render prop children, but look and read better than
// what we currently have. For example:
// 1.
// this sugar
function MyComponent(props) {
adopt foo from <Bar />;
return <div>{foo}</div>;
}
@lukecav
lukecav / functions.php
Last active November 18, 2021 16:52
Autoptimize Automatic Cache Purge - Set to be 2GB in size
// Automatically clear Autoptimize cache if it goes beyond 2GB
if (class_exists('autoptimizeCache')) {
$myMaxSize = 2000000; # You may change this value to lower like 500000 for 500MB if you have limited server space
$statArr=autoptimizeCache::stats();
$cacheSize=round($statArr[1]/1024);
if ($cacheSize>$myMaxSize){
autoptimizeCache::clearall();
header("Refresh:0"); # Refresh the page so that autoptimize can create new cache files and it does breaks the page after clearall.
}
@captainsafia
captainsafia / deploy.js
Last active September 16, 2017 11:06
A quick Node script to allow multi-environment deploys with now
#! /usr/bin/env node
'use strict';
const program = require('commander');
const fs = require('fs');
const { spawn } = require('child_process');
program
.version('1.0.0')
.option('-e, --environment <environment>', 'Environment to deploy to')
// https://github.com/kolodny/immutability-helper
/** Declaration extension point */
declare namespace ImmutabilityHelper {
interface CustomOperators<T> {
/* $someShit?: T */
/* $moreShit?: T */
}
}
@jacob-beltran
jacob-beltran / requestAnimationFrame.js
Last active April 17, 2020 04:05
React Performance: requestAnimationFrame Example
// How to ensure that our animation loop ends on component unount
componentDidMount() {
this.startLoop();
}
componentWillUnmount() {
this.stopLoop();
}
@retlehs
retlehs / sync-prod.sh
Last active January 26, 2022 03:48
WP-CLI aliases sync example
read -r -p "Would you really like to reset your development database and pull the latest from production? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
wp @development db reset --yes &&
wp @production db export - > sql-dump-production.sql &&
wp @development db import sql-dump-production.sql &&
wp @development search-replace https://example.com https://example.dev
fi
@Anubisss
Anubisss / README.md
Last active March 13, 2024 10:04
How to compile statically linked OpenVPN client for ARMv5

How to compile statically linked OpenVPN client for ARMv5

You need to install ARMv5 gcc cross compiler: apt-get install gcc-arm-linux-gnueabi

You have to define a directory (via --prefix) where all of your binaries will be installed (copied). In the guide I use the following: /home/user/vpn_compile

OpenSSL

  1. Download the source: wget https://www.openssl.org/source/openssl-1.0.2j.tar.gz
@developit
developit / async-examples.js
Last active February 19, 2020 00:43
Async Array utilities in async/await. Now available as an npm package: https://github.com/developit/asyncro
/** Async version of Array.prototype.reduce()
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => {
* acc[v] = await (await fetch(v)).json();
* return acc;
* }, {});
*/
export async function reduce(arr, fn, val, pure) {
for (let i=0; i<arr.length; i++) {
let v = await fn(val, arr[i], i, arr);
if (pure!==false) val = v;
@ControlledChaos
ControlledChaos / README.md
Last active September 21, 2023 05:54 — forked from saas786/sanitize_checkbox.php
Sanitization of WordPress Customizer controls

Sanitize the WordPress Customizer

WordPress Snippets