This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# fetch and cache artist id by doing a search | |
$spotresults = @json_decode(shell_exec('curl "https://api.spotify.com/v1/search?q='.$artistNameFromScrape.'&type=artist" -H "Accept: application/json"')); | |
$artistmeta = json_encode($spotresults->artists->items[0]); | |
$artistid = (string)$spotresults->artists->items[0]->id; | |
$artistname = (string)$spotresults->artists->items[0]->name; | |
$result = $db->prepare("INSERT INTO artists(artist, url, parent_artist, json) VALUES(?,?,?,?)"); | |
$result->execute(array($artistname, $val, 0, $artistmeta)); | |
$insert_id = $db->lastInsertId(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$artist_html = shell_exec('curl "http://schedule.sxsw.com/2017/artists"'); | |
preg_match_all('!<h4><a href="(.*?)">(.*?)</a></h4>!', $artist_html, $matches); | |
foreach($matches[1] as $i=>$val){ | |
print_r($matches[2][$i]." : ".$val."\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# hello | |
# this is pure crap, don't even think about using it | |
# it doesn't filter input vars or contain ANY error handling at all | |
# i wrote this while putting a kid to bed in, january 2016 | |
# i repeat: do not use this script | |
# i am peder@earthpeople.se, a ceo - not a real developer | |
# prerequisites | |
# you need an account at mathem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> | |
<script> | |
function checkApi(){ | |
// CRAPPY JQUERY SCRIPT BECAUSE I AM NOT A DEVELOPER (anymore) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set("Europe/Stockholm"); | |
require 'vendor/autoload.php'; | |
use GuzzleHttp\Pool; | |
use GuzzleHttp\Client; | |
$client = new Client(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(stristr($_SERVER['HTTP_USER_AGENT'], ' MSIE 9')){ | |
$msie_post = file_get_contents("php://input"); | |
parse_str($msie_post, $_POST); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$lockfile = '/tmp/cron_mylongrunningstuff.lock'; | |
if(file_exists($lockfile)){ | |
echo 'Hey, another process is already running, lockfile: '.$lockfile."\n"; | |
exit(0); | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import datetime | |
import time | |
import logging | |
try: | |
import MySQLdb as db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pika | |
import time | |
credentials = pika.credentials.PlainCredentials('guest', 'guest') | |
parameters = pika.ConnectionParameters( | |
host="127.0.0.1", | |
credentials=credentials) | |
connection = pika.BlockingConnection(parameters) | |
channel = connection.channel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hämta ut en array med dina likeade urlar | |
if($urls){ | |
foreach($urls as $url){ | |
# fetch stats from fb | |
$fbdata = @json_decode($this->curl->simple_get('http://api.facebook.com/restserver.php?method=links.getStats&urls='.$url.'&format=json')); | |
$likes = $fbdata ? $fbdata[0]->total_count : 0; | |
# uppdatera denna marker med hur många likes den har i databasen. nya värdet på likes finns i: $likes |
NewerOlder