Skip to content

Instantly share code, notes, and snippets.

View rolandinsh's full-sized avatar
🧔
Remote developer (LEMP / LAMP, Python, Flutter, Docker, AI)

Rolands rolandinsh

🧔
Remote developer (LEMP / LAMP, Python, Flutter, Docker, AI)
View GitHub Profile
@cachoimechi
cachoimechi / sha1.js
Created August 8, 2012 19:01
Javascript sha1 from webtoolkit
/**
*
* Secure Hash Algorithm (SHA1)
* http://www.webtoolkit.info/
*
**/
function SHA1 (msg) {
function rotate_left(n,s) {
@stevegrunwell
stevegrunwell / get_current_git_commit.php
Created August 15, 2012 21:44
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 {
@rezen
rezen / wp.filter.php
Created August 18, 2012 17:05
Filter Image insert for WordPress
function xf_insert_image( $html, $id, $caption, $title, $align, $url )
{
$html5 = "<figure id='post-$id media-$id' class='align-$align'>";
$html5 .= "<img src='$url' alt='$title' />";
$html5 .= "<figcaption>$caption</figcaption>";
$html5 .= "</figure>";
return $html5;
}
@nciske
nciske / get_meta_values.php
Created September 18, 2012 17:40
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'
@krmaxwell
krmaxwell / parsing.py
Created September 20, 2012 15:25
Meta tags and BeautifulSoup
from bs4 import BeautifulSoup
soup = BeautifulSoup(response)
metatags = soup.find_all('meta',attrs={'name':'generator'})
for tag in metatags:
print tag
@anointed
anointed / multi-ipn.php
Created September 30, 2012 02:42
Paypal multiple IPN's
<?php
/*
* This is a PayPal IPN (Instant Payment Notification) broadcaster
* Since PayPal does not provide any straightforward way to add
* multiple IPN listeners we'll have to create a central IPN
* listener that will broadcast (or filter and dispatch) Instant
* Payment Notifications to different destinations (IPN listeners)
*
* http://codeseekah.com/2012/02/11/how-to-setup-multiple-ipn-receivers-in-paypal/
*
@stephanieleary
stephanieleary / buddypress-spam-link.php
Created October 2, 2012 01:50
BuddyPress Spam Link plugin. Adds the "Mark as spammer" link back to the admin bar and adds a "Spammer" button to the activity stream entry meta row.
@amoilanen
amoilanen / webcrawler.js
Last active March 24, 2022 03:14
Simple PhantomJS-based web crawler library
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov anton.al.ivanov@gmail.com 2012
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler"
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist
(function(host) {
function Crawler() {
this.visitedURLs = {};
};
@rolandinsh
rolandinsh / gist:4270786
Created December 12, 2012 19:27
install a free startssl certificate in Plesk
in case it get lost http://www.jordicals.com/2010/04/how-to-install-a-free-startssl-certificate-in-plesk/
Here I leave you a trick about how to install a free startssl certificate in Plesk.
1 .- Validate in Plesk, go to the domain and then click to certificates.
2 .- Fill certificate data form (I recommend using 2048-bit), accept and send the request. This will generate the CSR key and private key.
3 .- Go to Startssl.com, make an account and go to the control panel. The first thing you must do is validate the corresponding domain at option validations option wizard -> domain name validation.
@mburst
mburst / rss_reader.php
Created March 24, 2013 03:58
RSS Feed Reader in PHP
<html>
<head>
<title>RSS Feed Reader</title>
</head>
<body>
<?php
//Feed URLs
$feeds = array(
"http://maxburstein.com/rss",
"http://www.engadget.com/rss.xml",