Skip to content

Instantly share code, notes, and snippets.

View mir4a's full-sized avatar
🤞

Myroslav mir4a

🤞
View GitHub Profile
@mir4a
mir4a / bookmarklet.js
Created May 28, 2013 14:37
Simple street parser from http://mosopen.ru/
javascript:
/**
* простой букмарклет, который парсит улицы из http://mosopen.ru/
*/
(function () {
var txt = "[";
var a = document.querySelectorAll(".double_part li > a");
for (var i=0;i<a.length;i++) {
var t = a[i].innerText;
txt += '"'+t+'",';
@mir4a
mir4a / photo-parser
Created June 7, 2013 14:20
Парсилка картинок
javascript:
/**
* простой букмарклет, который парсит фотки из http://www.kia-motors.com.ua/
*/
(function () {
var a = document.querySelectorAll(".galleryContainer > a");
var docHeight = document.height;
/**
* Создаю фон прелоадера
* @type {*}
@mir4a
mir4a / geolocation
Created June 12, 2013 10:41
Поиск города по ширине и долготе (из navigator.geolocation) через гугл-карты. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
geocoder = new google.maps.Geocoder();
function codeLatLng(latlng) {
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
var city = results[1]["address_components"][2]["short_name"];
var setPhone;
@mir4a
mir4a / KIA PARSER
Last active December 18, 2015 14:09
очередной букмарклет парсер, но уже для kia.ua
javascript:
/**
* простой букмарклет, который парсит фотки из http://www.kia.ua/
*/
(function () {
var a = document.querySelectorAll("#thumbs .thumbs .thumb");
var docHeight = document.height;
/**
* Создаю фон прелоадера
* @type {*}
@mir4a
mir4a / batch rename terminal
Created September 13, 2013 15:13
Batch rename file extensions (bash)
for i in *.ext; do mv -- "$i" "${i%.ext}.otherext"; done
@mir4a
mir4a / gist:6970102
Created October 14, 2013 03:10
Create new posts using terms as reference
INSERT INTO wp_posts (post_author,post_date,post_date_gmt,post_modified,post_modified_gmt,post_content,post_title,post_status,post_name,post_type,mmm_term_id)
SELECT '1',now(),now(),now(),now(),'db_flow',name,'draft',slug,'course',term_id
FROM wp_terms
@mir4a
mir4a / gist:6970485
Created October 14, 2013 03:55
Update custom field mmm_term_id for lesson posts type that has category taxonomy
UPDATE `wp_posts`, `wp_term_relationships`
SET `wp_posts`.`mmm_term_id` = `wp_term_relationships`.`term_taxonomy_id`
WHERE `wp_posts`.`ID` = `wp_term_relationships`.`object_id` AND `wp_posts`.`post_type` = 'lesson'
@mir4a
mir4a / gist:6970581
Created October 14, 2013 04:05
Insert new relation for lessons to join them with courses
INSERT INTO `wp_postmeta` (`post_id`,`meta_key`,`meta_value`)
SELECT ID,'_lesson_course',`mmm_term_id`
FROM `wp_posts` WHERE `post_type` = 'lesson'
@mir4a
mir4a / gist:6970611
Created October 14, 2013 04:08
Publish all draft courses
UPDATE `wp_posts`
SET `wp_posts`.`post_status` = 'publish'
WHERE `wp_posts`.`post_type` = 'course'
@mir4a
mir4a / airplane colours
Created December 24, 2013 16:43
What if airplanes got their own hex-colours by their models? Here is sample colour vars for sass lang
$boeing_787: #787;
$boeing_777: #777;
$boeing_767: #767;
$boeing_747: #747;
$boeing_737: #737;
$airbus_320: #320;
$airbus_330: #330;
$airbus_340: #340;
$airbus_350: #350;