Skip to content

Instantly share code, notes, and snippets.

View Ruzzz's full-sized avatar

Ruslan Zaporojets Ruzzz

View GitHub Profile
@Ruzzz
Ruzzz / speed_limit.php
Last active October 12, 2015 21:18
Php | Test | Speed limit
<?php
$filename = $_GET['file'];
$downloadRate = isset($_GET['speed']) ? intval($_GET['speed']) : 500;
if (file_exists($filename) && is_file($filename))
{
header('Cache-control: private');
header('Content-Type: application/x-shockwave-flash'); // Set MIME
header('Content-Length: '.filesize($filename));
@Ruzzz
Ruzzz / ant_build_opera_ext.xml
Last active February 2, 2016 16:23
Example | Build Opera extension (ANT)
<?xml version="1.0"?>
<project name="OperaExtensionBuild" default="build-opera-extension" basedir=".">
<!-- Vars -->
<property name="main-url" value="EXT-PAGE-URL"></property>
<property name="release-base-url" value="UPDATE-BASE-URL"></property>
<property name="config-file" value="config.xml"/>
<property name="src-dir" value="src"/>
<property name="release-dir" value="release"/>
<property name="temp-dir" value="temp"/>
@Ruzzz
Ruzzz / oem_logon_background.bat
Created November 16, 2012 19:02
Windows OEM Logon Background Enable
REM run as admin, picture must be JPEG, picture size must be not more than 256KB
REM SET img_path=%1 or SET img_path="path to jpg" or
SET img_path=%~dp0background.jpg
SET bg_path=%SystemRoot%\system32\oobe\info\backgrounds
MD %bg_path%
COPY %img_path% %bg_path%\BackgroundDefault.jpg
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" /v OEMBackground /t REG_DWORD /d 1 /f
REM Shadow of controls: 0 - transparent shadow, 1 - shadow, 2 - no shadow
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" /v ButtonSet /t REG_DWORD /d 1 /f
@Ruzzz
Ruzzz / encode_dom_to_url.js
Created November 16, 2012 19:11
Encode DOM to URL
(function () {
// From http://www.webtoolkit.info/javascript-base64.html
var Base64 = {
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
@Ruzzz
Ruzzz / fast_x86_math_func.c
Created November 16, 2012 19:32
Быстрые мат. функции на си (нашел где-то)
int floor(float a)
{
int b = (int)a;
if (a >= 0 || (a - b) == 0)
return b;
else
return b - 1;
}
int trunc(float r)
@Ruzzz
Ruzzz / simple_parser.cpp
Created November 16, 2012 19:47
C++ Simple Parser
template <class T, class CharType>class Parser
{
Parser(T &t) :: m_curr(t.begin()) , m_end(t.end()) {}
bool next_char(CharType *c) {
bool not_eof = m_curr != m_end;
if (not_eof) {
*c = *m_curr;
m_curr++;
}
@Ruzzz
Ruzzz / AStyle_for_Notepade++_and_VS.txt
Last active October 12, 2015 21:38
My AStyle Settings (Notepade++,Visual Studio)
See http://sourceforge.net/projects/astyle/
Notepade++
Script for NppExec:
NPP_SAVE
cd $(CURRENT_DIRECTORY)
с:\apps\dev\AStyle\AStyle.exe -A1 -s4 -S -w -Y -m0 -M120 -p -H -U -k3 -W3 -xj -c -xy -Z -z1 "$(FILE_NAME)"
Visual Studio
@Ruzzz
Ruzzz / GoogleClosureCompiler_for_Notepade++.txt
Last active October 12, 2015 21:39
Google Closure Compiler for Notepade++
Script for NppExec:
NPP_SAVE
cd $(CURRENT_DIRECTORY)
java -jar f:\apps\dev\GoogleClosureCompiler\compiler.jar --js "$(FILE_NAME)" --js_output_file "$(NAME_PART)_min$(EXT_PART)"
@Ruzzz
Ruzzz / min_win32_gui_app.cpp
Created November 16, 2012 20:01
Minimal Windows GUI Program
#include <windows.h>
static TCHAR szWindowClass[] = TEXT("MinAppWindowClass");
static TCHAR szTitle[] = TEXT("Min App");
HINSTANCE hInst;
HWND hWnd;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
@Ruzzz
Ruzzz / prepareForDom.php
Last active January 15, 2017 14:12
Функция подготовки html-кода для работы с DOM — решает проблемы с кириллицей
<?php
function prepareForDOM($html, $inCharset) {
if ($inCharset != 'utf8' && $inCharset != 'utf-8')
$html = iconv($inCharset, 'UTF-8//TRANSLIT', $html);
$html = preg_replace('/<(script|style|noscript)\b[^>]*>.*?<\/\1\b[^>]*>/is', '', $html);
$tidy = new tidy;
$config = array( // See http://tidy.sourceforge.net/docs/quickref.html
'drop-font-tags' => true,
'drop-proprietary-attributes' => true,
'hide-comments' => true,