Skip to content

Instantly share code, notes, and snippets.

@martinmev
martinmev / Microsoft.PowerShell_profile.ps1
Last active May 25, 2019 21:23
PowerShell Core / Windows PowerShell - Workaround for non-US keyboard layout and Unicode code page
# Workaround for https://github.com/PowerShell/PSReadLine/pull/768
# Downgrade PS-Readline
# Install-Module -Name PSReadLine -RequiredVersion 1.2 -SkipPublisherCheck
# Install less pager
# https://www.guysalias.tk/misc/less/
# Unicode code page
chcp 65001
@martinmev
martinmev / uc_gp.pages.inc.patch
Created January 14, 2018 18:04
Patch for Ubercart 6 Global Payments Webpay (GP) integration (Drupal 6; logging and digest1 checking)
diff --git a/www/sites/all/modules/uc_gp/uc_gp.pages.inc b/www/sites/all/modules/uc_gp/uc_gp.pages.inc
index 62b18da..2a1137f 100644
--- a/www/sites/all/modules/uc_gp/uc_gp.pages.inc
+++ b/www/sites/all/modules/uc_gp/uc_gp.pages.inc
@@ -41,6 +41,12 @@ function uc_gp_webpay_request($order) {
// Create full URL
$url = url($action, array('query' => $values));
+ $values_s = "";
+ foreach ($values as $key => $value) {
@martinmev
martinmev / drupal6_cache.patch
Created October 8, 2017 22:09
Patch for Drupal6 (and Pressflow6 too) cache
diff --git a/www/includes/cache.inc b/www/includes/cache.inc
index 1e70960..d08f3f4 100644
--- a/www/includes/cache.inc
+++ b/www/includes/cache.inc
@@ -17,9 +17,9 @@ function cache_get($cid, $table = 'cache') {
// Garbage collection necessary when enforcing a minimum cache lifetime
$cache_flush = variable_get('cache_flush_'. $table, 0);
- if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= time())) {
+ if ($cache_flush + variable_get('cache_lifetime', 0) <= time()) {
@martinmev
martinmev / .xonshrc
Last active June 22, 2018 18:57
Xonsh: "c" - creates pretty part of the URL, "resizeDir" - resize and auto orient images in given directory
import unicodedata
def cData_(x):
s = unicodedata.normalize('NFKD', x).encode('ascii', 'ignore').lower().decode('ascii')
newS = ''.join(map(lambda x: x if x.isalnum() else '-', s))
oldS = None
while oldS != newS:
oldS = newS
newS = newS.replace('--', '-')
if newS:
@martinmev
martinmev / Readme.txt
Created January 9, 2017 22:51
Patch for Ubercart hidden checkout error
Patch for Ubercart hidden checkout error
Uc_cart version: 6.x-2.15
Drupal version: 6.38
Ubercart hidden checkout error:
No error message appeared when the database connection error occurred.
The drupal user wasn't created and the customer received only one email (below) with the account settings but the username was empty.
The order remained in the state "in checkout".
@martinmev
martinmev / characterSetMappingTables.jl
Last active August 29, 2015 14:20
This Julia Gist generates the character set mapping dictionaries from the mappings files (8 bit characters to Unicode; ftp.unicode.org/Public/MAPPINGS/) and it decodes the text from a given code page.
using HDF5, JLD
# https://www.dropbox.com/s/o4ys5z3p7ogircd/characterSetMappingTables.jld?dl=0
@load "c:\\Users\\Martin\\Downloads\\MAPPINGS\\characterSetMappingTables.jld"
function printEncodings()
for mappingTable in sort(collect(keys(characterSetMappingTables)))
println(mappingTable)
end
end
@martinmev
martinmev / touchtest.html
Last active August 29, 2015 14:16
Detection (Javascript): Click (Desktop) or Touch (Touch device)?
<html>
<body>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script language="javascript">
mouseOverTime = 0;
@martinmev
martinmev / gist:444619fbdec82864a025
Created June 1, 2014 11:18
Export contacts from Nokia Suite
import sqlite3
import json
conn = sqlite3.connect('c:\\Users\\Martin\\AppData\\Local\\Nokia\\Nokia Data Store\\DataBase\\MDataStore.db3')
data = {}
cursor = conn.execute("select * from contact")
rows = cursor.fetchall()
getRowData = lambda r : ' '.join([x if x else '' for x in r]).strip()
@martinmev
martinmev / gist:fdc3462e62b039a910c4
Created June 1, 2014 11:09
Dump Nokia Suite SQLite database
import sqlite3
conn = sqlite3.connect('c:\\Users\\Martin\\AppData\\Local\\Nokia\\Nokia Data Store\\DataBase\\MDataStore.db3')
for i in conn.iterdump():
print(i)
@martinmev
martinmev / gist:2b219d7684b73692c96f
Last active January 29, 2016 20:33
Drupal HTML article: Delete the teaser image and display the first image (from Drupal Galleria module) in Lightbox (on click).
<script type="text/javascript">
<!--
try { $('.Image')[0].outerHTML=''; } catch(err) {};
-->
</script></p>
<p><a href="#" onclick="Lightbox.start(
$('#galleria-content ul.galleria li a:eq(0)')[0]);
return false;"><img src="/sites/default/files/posli_to_dal2.jpg" style="float: left;"/></a></p>