Skip to content

Instantly share code, notes, and snippets.


Andrei Glingeanu andreiglingeanu

View GitHub Profile
andreiglingeanu /
Created Mar 15, 2020 — forked from jlblancoc/
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:

andreiglingeanu /
Last active Mar 15, 2020 — forked from isaacs/
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at Note: npm >=0.3 is *safer* when using sudo.
sudo apt-get update
sudo apt-get install build-essential openssl libssl-dev pkg-config
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
andreiglingeanu / Hoverable.js
Created Nov 9, 2018 — forked from necolas/Hoverable.js
Hover styles in React Native for Web
View Hoverable.js
import createHoverMonitor from './createHoverMonitor';
import { element, func, oneOfType } from 'prop-types';
import React, { Component } from 'react';
const hover = createHoverMonitor();
* Use:
* <Hoverable>
* {(hover) => <View style={hover && styles.hovered} />}
andreiglingeanu /
Created Nov 30, 2017 — forked from willurd/
Set the Desktop Background for all of your open Spaces in Mountain Lion
read -e IMAGE;
defaults write Background "{default = {ImageFilePath='$IMAGE'; };}"
killall Dock
View .pryrc
# Using these pry gems
# gem "pry"
# gem "pry-rails"
# gem "pry-byebug"
# gem "pry-stack_explorer"
# gem "pry-doc"
# gem "pry-state"
# gem "pry-toys"
# gem "pry-rescue"
andreiglingeanu / wp-image-crop-position.php
Created Aug 8, 2017 — forked from bradt/wp-image-crop-position.php
WordPress: Set an image's crop position and rotates images based on EXIF information if necessary
View wp-image-crop-position.php
/* Example Usage:
* bt_add_image_size( 'product-screenshot', 300, 300, array( 'left', 'top' ) );
* bt_add_image_size( 'product-feature', 460, 345, array( 'center', 'top' ) );
add_filter( 'intermediate_image_sizes_advanced', 'bt_intermediate_image_sizes_advanced' );
add_filter( 'wp_generate_attachment_metadata', 'bt_generate_attachment_metadata', 10, 2 );
andreiglingeanu /
Created Dec 23, 2016 — forked from retlehs/
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])$ ]]
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
exit 0
andreiglingeanu / url-to-domain.php
Created Oct 17, 2016
PHP: Get the domain name from a URL for display purposes
View url-to-domain.php
// This is PHP function to convert a user-supplied URL to just the domain name,
// which I use as the link text.
// Remember you still need to use htmlspecialchars() or similar to escape the
// result.
function url_to_domain($url)
andreiglingeanu /
Created Oct 4, 2016 — forked from bjornjohansen/
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
# Copyright © 2015 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See for more details.
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
andreiglingeanu / dapply
Created Jul 29, 2016 — forked from cam8001/dapply
Apply a patch directly from a URL without downloading it first.
View dapply
# Downloads and applies a patch from
if [ -z "$1" ]
echo "You need to supply a URL to a patch file."