Skip to content

Instantly share code, notes, and snippets.

// git clone https://github.com/Vastly/vkontakte-php-sdk
require_once('../src/Vkontakte.php');
$accessToken = 'your access token';
$vkAPI = new \BW\Vkontakte(['access_token' => $accessToken]);
$publicID = 70941690;
if ($vkAPI->postToPublic($publicID, "Привет Хабр!", '/tmp/habr.png', ['вконтакте api', 'автопостинг', 'первые шаги'])) {
echo "Ура! Всё работает, пост добавлен\n";
vlc.exe "inputVideo.mp4" --fullscreen --no-mouse-events --loop --no-osd --no-audio
# I like how Rails has each controller in it's own file and it's automatically loaded and I'm trying to do the same for my Sinatra site.
# I have, for example, my "Users" pages, which is users/login, users/logout and so on, what I'd like to do is seperate all these, and other pages, like news, admincp, and so on into their own files.
# This is how I accomplished this with my project.
# I put all the "controllers" in a directory, I then created a file named init.rb with the following code:
Dir.glob(File.dirname(__FILE__) + '/*.rb').each do |controller|
require(controller)
end
@skive
skive / export_csv.php
Created February 27, 2016 21:27 — forked from apocratus/export_csv.php
Export MySQL to CSV (php script)
<?php
/* vars for export */
// database record to be exported
$db_record = 'XXXXXXXXX';
// optional where query
$where = 'WHERE 1 ORDER BY 1';
// filename for export
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv';
// database variables
<?php
/**
* The list of countries and dependent territories based on ISO 3166 standard.
*
* Source: http://en.wikipedia.org/wiki/ISO_3166-1 ISO 3166-1
*/
class Listo_Countries implements Listo {
private static $items = array(
'rus' => "Российская Федерация",
server {
listen [port];
server_name [web url];
access_log [access_log_location];
error_log [error_log_location];
root [where_to_serve from];
index index.html index.php;
# If file is an asset, set expires and break
server{
listen [port];
server_name [url] [www.url];
access_log [access_log_location];
error_log [error_log];
root [where_to_serve_from];
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
try {
$db = new PDO($config['db_driver'] . ":dbname=" . $config['db_name'] . ";host=" . $config['db_host'], $config['db_user'], $config['db_pass']);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->query("SET NAMES '{$config['db_charset']}'");
} catch (PDOException $e) {
exit("Database connection error!");
}
@skive
skive / gist:a066b4712aed880f3245
Created March 11, 2016 18:00
Script to block MS telemetry using Mikrotik router
/ip firewall address-list add list=MStelemetry address=111.221.29.177
/ip firewall address-list add list=MStelemetry address=111.221.29.253
/ip firewall address-list add list=MStelemetry address=131.253.40.37
/ip firewall address-list add list=MStelemetry address=134.170.30.202
/ip firewall address-list add list=MStelemetry address=134.170.115.60
/ip firewall address-list add list=MStelemetry address=134.170.165.248
/ip firewall address-list add list=MStelemetry address=134.170.165.253
/ip firewall address-list add list=MStelemetry address=134.170.185.70
/ip firewall address-list add list=MStelemetry address=137.116.81.24
/ip firewall address-list add list=MStelemetry address=137.117.235.16
@skive
skive / functions.php
Created May 30, 2019 17:59 — forked from JakePT/functions.php
Filter to stop WordPress replacing spaces with dashes in filenames.
<?php
/**
* A copy of WordPress' sanitize_file_name function that doesn't replace
* spaces with dashes. Use on the sanitize_file_name filter to stop WordPress
* replacing filenames with dashes.
*
* ...Or don't. It's probably a bad idea.
*
* @param string $sanitized_filename The previously sanitized filename.
* @param string $filename The original unsanitized filename.