Skip to content

Instantly share code, notes, and snippets.

View rolandinsh's full-sized avatar
🧔
Remote developer (LEMP, Node.js, Neo4j [graph])

Rolands rolandinsh

🧔
Remote developer (LEMP, Node.js, Neo4j [graph])
View GitHub Profile
<?php
function get_url_contents($url){
if (function_exists('file_get_contents')) {
$result = @file_get_contents($url);
}
if ($result == '') {
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $url);
@rolandinsh
rolandinsh / namedays-extended.json
Last active March 25, 2022 16:39 — forked from laacz/namedays-extended.json
Vārdadienas JSON (par prieku Sergejam)
{
"01-01": ["Afra", "Afrodīte", "Agunda", "Agurs", "Januārija", "Laimstars", "Soleda", "Solita", "Solveta"],
"01-02": ["Induls", "Īva", "Ivaise", "Ivija", "Īvija", "Ivika", "Īvis", "Ivisa", "Ivs"],
"01-03": ["Ambrozijs", "Ammonārija", "Ammunārija", "Mežvaldis", "Mieriņš", "Miermīlis", "Miernesis", "Miervalds", "Ringla", "Ringo", "Rinolds"],
"01-04": ["Amina", "Amīna", "Amirans", "Amirs", "Blāzma", "Ilveta", "Ilvis", "Spodrīte"],
"01-05": ["Amrita", "Amunds", "Anarita", "Saimona", "Saimons", "Seimanis", "Semions", "Semjons", "Simeons", "Simions", "Zintauts", "Zinturs"],
"01-06": ["Arams", "Aranta", "Arfa", "Arnīda", "Arnija", "Arnika"],
"01-07": ["Julians", "Jūlians", "Jūliāns", "Sigmars", "Sigmārs", "Zigmāra", "Zigmāris", "Zigmars"],
"01-08": ["Ants", "Aristarhs", "Aristida", "Aristīda", "Aristids", "Aristīds", "Aristons", "Aristrīds", "Arjana", "Arlands", "Arleta", "Arlēna", "Arlijs", "Arlita", "Gatiņš", "Īvande", "Ivanna", "Ivase", "Ivena"],
"01-09": ["Aksela", "Akselis",
@rolandinsh
rolandinsh / get_meta_values.php
Created November 11, 2018 15:04 — forked from nciske/get_meta_values.php
WordPress Getting all values for a custom field key
// http://wordpress.stackexchange.com/questions/9394/getting-all-values-for-a-custom-field-key-cross-post
function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {
global $wpdb;
if( empty( $key ) )
return;
$r = $wpdb->get_col( $wpdb->prepare( "
SELECT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
@rolandinsh
rolandinsh / PHP-CURL-Tor-Tutorial.md
Last active August 11, 2023 18:44 — forked from megaxorg/PHP-CURL-Tor-Tutorial.md
PHP: CURL Requests with Tor

#CURL Connections with Tor

Install Apache, PHP, CURL & Tor with apt-get

sudo apt-get install -y apache2 php php-curl tor

Tor creates a proxy on your mashine with port 9050 for SOCKS5 connections.

@rolandinsh
rolandinsh / get_current_git_commit.php
Created May 10, 2017 00:06 — forked from stevegrunwell/get_current_git_commit.php
Get current git HEAD using PHP
<?php
/**
* Get the hash of the current git HEAD
* @param str $branch The git branch to check
* @return mixed Either the hash or a boolean false
*/
function get_current_git_commit( $branch='master' ) {
if ( $hash = file_get_contents( sprintf( '.git/refs/heads/%s', $branch ) ) ) {
return $hash;
} else {
@rolandinsh
rolandinsh / gist:170141e1add053ca9879064673a24a69
Last active February 6, 2017 00:51
Installing Neo4j on Ubuntu
cd ~
wget -O - http://debian.neo4j.org/neotechnology.gpg.key >> key.pgp
sudo apt-key add key.pgp
echo 'deb http://debian.neo4j.org/repo stable/' | sudo tee -a /etc/apt/sources.list.d/neo4j.list > /dev/null
sudo apt-get update && sudo apt-get install neo4j
sudo service neo4j (stop|start|restart)
@rolandinsh
rolandinsh / ga-event-tracker.js
Created February 2, 2017 12:34 — forked from cheynewallace/ga-event-tracker.js
jQuery Google Analytics Event Tracking Using HTML Attributes
/*JSHint Options*/
/*global _gaq */
/*
Google Analytics Event Tracking - JSHint Checked
Written By Cheyne Wallace - 19th Nov 2012
Click Usage: <a href="http://somewhere"
class="ga-track"
event_category="Event Category"
event_action="Specific Action"
event_label="Optional Message"
via http://wordpress.stackexchange.com/questions/2623/include-custom-taxonomy-term-in-search/5404#5404
function atom_search_where($where){
global $wpdb;
if ( is_search() )
$where .= "OR (t.name LIKE '%".get_search_query() . "%' AND {$wpdb->posts} . post_status = 'publish')";
return $where;
}
<?php
if ( ! function_exists( 'ucc_nav_menu_css_class' ) ) {
function ucc_nav_menu_css_class( $classes, $item, $args ) {
$class = sanitize_title( $item->title );
$classes[] = 'menu-item-' . $class;
return $classes;
} }
add_filter( 'nav_menu_css_class', 'ucc_nav_menu_css_class', 10, 3 );
@rolandinsh
rolandinsh / gist:3263895
Created August 5, 2012 10:58 — forked from kloon/gist:2376300
WooCommerce Automatically add product to cart on site visit
/*
* goes in theme functions.php or a custom plugin
**/
// add item to cart on visit
add_action( 'init', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 64;
$found = false;