Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrei Glingeanu andreiglingeanu

View GitHub Profile
View metabox.php
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => esc_html__( 'Untitled Field Group', 'online-generator' ),
'id' => 'untitled',
View helpers.js
// helpers.js
const loadSingleEntryPoint = ({
// Elements selectors
els = [],
// Execute something before the actual load of the module
beforeLoad = (el) => {},
// Perform module load & return a Promise
View clean.sh
rm -rf "~/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle"
View installnode.sh
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
nvm install node
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
@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...
View replace-vars.js
// Make all variables dashed-case
// USAGE:
// ack -l -- '--\b' | xargs node replace-vars.js
const { readFileSync, writeFileSync } = require('fs')
const [_, __, ...files] = process.argv
console.log(files)
const camelCaseToDash = myStr =>
myStr.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
View test.php
<?php
class Parser {
public function add_attribute_to_images(
$content,
$attribute_name,
$attribute_value
) {
$new_content = $this->add_attribute_to_images_with_tag(
$content,
@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} />}
View get-empty-port.sh
#!/bin/bash
netstat -aln | awk '
$6 == "LISTEN" {
if ($4 ~ "[.:][0-9]+$") {
split($4, a, /[:.]/);
port = a[length(a)];
p[port] = 1
}
}
END {