Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrei Glingeanu andreiglingeanu

View GitHub Profile
@andreiglingeanu
andreiglingeanu / Install_gcc7_ubuntu_16.04.md
Created Mar 15, 2020 — forked from jlblancoc/Install_gcc7_ubuntu_16.04.md
Installing gcc-7 & g++-7 in Ubuntu 16.04LTS Xenial
View Install_gcc7_ubuntu_16.04.md

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
andreiglingeanu / node-and-npm-in-30-seconds.sh
Last active Mar 15, 2020 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
View node-and-npm-in-30-seconds.sh
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 http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
@andreiglingeanu
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
andreiglingeanu / set-wallpaper.sh
Created Nov 30, 2017 — forked from willurd/ set-wallpaper.sh
Set the Desktop Background for all of your open Spaces in Mountain Lion
View set-wallpaper.sh
read -e IMAGE;
defaults write com.apple.desktop 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
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
<?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
andreiglingeanu / sync-prod.sh
Created Dec 23, 2016 — forked from retlehs/sync-prod.sh
WP-CLI aliases sync example
View sync-prod.sh
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
else
exit 0
fi
@andreiglingeanu
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
<?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
andreiglingeanu / run-wp-cron.sh
Created Oct 4, 2016 — forked from bjornjohansen/run-wp-cron.sh
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
View run-wp-cron.sh
#!/bin/bash
# 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 http://www.wtfpl.net/ for more details.
WP_PATH="/path/to/wp"
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
@andreiglingeanu
andreiglingeanu / dapply
Created Jul 29, 2016 — forked from cam8001/dapply
Apply a patch directly from a URL without downloading it first.
View dapply
#!/bin/bash
# Downloads and applies a patch from Drupal.org.
if [ -z "$1" ]
then
echo "You need to supply a URL to a patch file."
exit
fi
URL=$1;