Do you want to create an UIColor from RGB value?
Here the snipplet:
1 2 3 4 | #define UIColorFromRGB(rgbValue) [UIColor \ colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] |
to use:
1 | UIColor aColor = UIColorFromRGB(0xFF00FF); |
it’s all!
Hello,
I found a magic trick for windows… it use WMIC.
Using WMIC, it is possible to list out all the running processes and their parameters!
The following command-line outputs the list of running processes (with the complete command-line arguments used for each process) to a text file:
1 | WMIC /OUTPUT:C:\ProcessList.txt path win32_process get Caption,Processid,Commandline |
ffmpeg.exe -y -i “DEC_M6_U1_L3_R.avi” [...] “DEC_M6_U1_L3_R.mp4″
I’m happy!
Rif: albertopasca.it
Well,
a usefully thing (for me) that convert real media files like CAMV, RM, SMIL in iPod compatible video (AVI mpeg4).
It’s a multithread windows executable easy to use.
It merge RM and CAMV in AVI file and after convert the AVI in Mpeg4 for iPod compatible video in 320×240.

you can download it here.
If you prefer unix version of rm camv converter, read this old article.
WARNING! It’s a beta version 000000.000001 ! There are a lot of bugs… but it works!
it’s all.
Rif: albertopasca.it
Yes!
It’s double right click!
In this snippet you can use right double click to “go back” on your web browser!
It’s a stupid tricks, but it’s very useful!
Here we go!
As usually, copy and paste this snippet in your windows application.
First of all, you must include this libs:
using System.Runtime.InteropServices;
using System.Diagnostics;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | private static LowLevelMouseProc _proc = HookCallback; private static IntPtr _hookID = IntPtr.Zero; private static MSLLHOOKSTRUCT _posDblClk; private const int WH_MOUSE_LL = 14; private enum MouseMessages { WM_LBUTTONDOWN = 0x0201, WM_LBUTTONUP = 0x0202, WM_MOUSEMOVE = 0x0200, WM_MOUSEWHEEL = 0x020A, WM_RBUTTONDOWN = 0x0204, WM_RBUTTONUP = 0x0205 } [StructLayout( LayoutKind.Sequential )] private struct POINT { public int x; public int y; } [StructLayout( LayoutKind.Sequential )] private struct MSLLHOOKSTRUCT { public POINT pt; public uint mouseData; public uint flags; public uint time; public IntPtr dwExtraInfo; } [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )] private static extern IntPtr SetWindowsHookEx( int idHook, LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId ); [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )] [return: MarshalAs( UnmanagedType.Bool )] private static extern bool UnhookWindowsHookEx( IntPtr hhk ); [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )] private static extern IntPtr CallNextHookEx( IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam ); [DllImport( "kernel32.dll", CharSet = CharSet.Auto, SetLastError = true )] private static extern IntPtr GetModuleHandle( string lpModuleName ); |
Ok, this is first part of code, used to catch mouse event with windows API like kernel32.dll and user32.dll.
After that, create two simple method that invoke mouse hook:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | private static IntPtr SetHook( LowLevelMouseProc proc ) { using ( Process curProcess = Process.GetCurrentProcess() ) using ( ProcessModule curModule = curProcess.MainModule ) { return SetWindowsHookEx( WH_MOUSE_LL, proc, GetModuleHandle( curModule.ModuleName ), 0 ); } } private delegate IntPtr LowLevelMouseProc( int nCode, IntPtr wParam, IntPtr lParam ); private static IntPtr HookCallback( int nCode, IntPtr wParam, IntPtr lParam ) { if ( nCode >= 0 && MouseMessages.WM_RBUTTONDOWN == ( MouseMessages )wParam ) { MSLLHOOKSTRUCT hookStruct = ( MSLLHOOKSTRUCT )Marshal.PtrToStructure( lParam, typeof( MSLLHOOKSTRUCT ) ); if ( ( _posDblClk.pt.x == hookStruct.pt.x ) && ( _posDblClk.pt.y == hookStruct.pt.y ) ) { SendKeys.Send( "%{LEFT}" ); } _posDblClk.pt.x = hookStruct.pt.x; _posDblClk.pt.y = hookStruct.pt.y; } return CallNextHookEx( _hookID, nCode, wParam, lParam ); } |
…you can view that in HookCallback function there is a method that use “%{LEFT}”, this is equivalent to ALT+LEFTARROW, used to go back in web browser.
SendKeys.Send( “%{LEFT}” );
When is detected a double right click, the program send to the system the ALT+LEFTARROW keys. If you are in a browser, you go back!
Finally,
in you form init, insert this lines
1 2 3 | _hookID = SetHook( _proc ); Application.Run(); UnhookWindowsHookEx( _hookID ); |
that starting the mouse hook.
Perfect! Compile and test it!
If you like this tricks, add it in Windows Autorun!
If you like this post, click iLike!
If you don’t want to compile and want only to use it, you can download from here.
byz
Rif: albertopasca.it
Hello,
a simple trick for you to get pixel color on a particular position of your screen with Windows GDI32.dll API libs.
First of all, you need to import Win32 API:
1 2 3 4 5 6 7 8 | [DllImport( "user32.dll" )] static extern IntPtr GetDC( IntPtr hwnd ); [DllImport( "user32.dll" )] static extern Int32 ReleaseDC( IntPtr hwnd, IntPtr hdc ); [DllImport( "gdi32.dll" )] static extern uint GetPixel( IntPtr hdc, int nXPos, int nYPos ); |
after that, create a function like this that return color in ARGB:
1 2 3 4 5 6 7 8 9 10 | static public System.Drawing.Color GetPixelColor( int x, int y ) { IntPtr hdc = GetDC( IntPtr.Zero ); uint pixel = GetPixel( hdc, x, y ); ReleaseDC( IntPtr.Zero, hdc ); Color color = Color.FromArgb( ( int )( pixel & 0x000000FF ), ( int )( pixel & 0x0000FF00 ) >> 8, ( int )( pixel & 0x00FF0000 ) >> 16 ); return color; } |
you can call it simply GetPixelColor( 0, 100 );
That’s all.
Rif: albertopasca.it
As a Linux user, you may have to get the following error:
bash: /bin/rm: Argument list too long
There are a lot of methods to resolve this issue, but I use this stupid and simple one:
Here the code (copy, type vi rmany.sh, paste the code):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # # rmany.sh # - List or delete a lot of files... # ...specially in this folder! # # (c)apasca # # #!/bin/bash # for X in *.$1 do $2 "$X"; done # # FIRST: # chmod +x rmany.sh # alias rmany='./rmany.sh' # # USAGE: # rmany [EXTENSION] [COMMAND] # |
You need to make it executable (chmod +x rmany.sh) and optionally add it as alias (alias rmany=’./rmany.sh’).
Your input is rmany [EXTENSION] [COMMAND]
!
Apple: iPhone 4 reception problem is a software issue, fix coming in ‘a few weeks’
Upon investigation, we were stunned to find that the formula we use to calculate how many bars of signal strength to display is totally wrong. Our formula, in many instances, mistakenly displays 2 more bars than it should for a given signal strength. For example, we sometimes display 4 bars when we should be displaying as few as 2 bars. Users observing a drop of several bars when they grip their iPhone in a certain way are most likely in an area with very weak signal strength, but they don’t know it because we are erroneously displaying 4 or 5 bars. Their big drop in bars is because their high bars were never real in the first place.
To fix this, we are adopting AT&T’s recently recommended formula for calculating how many bars to display for a given signal strength. The real signal strength remains the same, but the iPhone’s bars will report it far more accurately, providing users a much better indication of the reception they will get in a given area. We are also making bars 1, 2 and 3 a bit taller so they will be easier to see.
We will issue a free software update within a few weeks that incorporates the corrected formula. Since this mistake has been present since the original iPhone, this software update will also be available for the iPhone 3GS and iPhone 3G.
Rif: http://www.engadget.com/2010/07/02/apple-iphone-4-reception-problems-a-software-issue-fix-coming/
Hello!
if you like linux or mac os, you should also like the windows dragging cool trick right?
In linux you can drag windows anywhere by pressing ALT+CLICK… I’m not sure, but it should be the same thing in OS X.
Googling around… I found an interesting article in howtogeek.com that explains how to do that in Windows OS!!
The original script is here:
http://www.autohotkey.com/docs/scripts/EasyWindowDrag.htm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | Alt & LButton:: CoordMode, Mouse MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin% WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin% if EWD_WinState = 0 SetTimer, EWD_WatchMouse, 10 return EWD_WatchMouse: GetKeyState, EWD_LButtonState, LButton, P if EWD_LButtonState = U { SetTimer, EWD_WatchMouse, off return } GetKeyState, EWD_EscapeState, Escape, P if EWD_EscapeState = D { SetTimer, EWD_WatchMouse, off WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY% return } CoordMode, Mouse MouseGetPos, EWD_MouseX, EWD_MouseY WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin% SetWinDelay, -1 WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY EWD_MouseStartX := EWD_MouseX EWD_MouseStartY := EWD_MouseY return |
Oh, you want the complete package?
Ok ok… click here, extract it and put it in Autorun of your Winz.
If you want to write and compile you personalized version, I have coded a C# version, easy to use!
First of all, include Win32API in your code. This library is needed to send events to external windows.
1 2 3 4 5 6 | [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = false )] static extern IntPtr SendMessage( int hWnd, uint Msg, int wParam, int lParam ); [DllImportAttribute( "user32.dll", CharSet = CharSet.Auto, SetLastError = false )] public static extern bool ReleaseCapture(); [DllImport( "user32.dll" )] static extern int GetForegroundWindow(); |
After that, set a timer and call GetForegroundWindow() just like this:
1 | int handle = GetForegroundWindow(); |
Now, create the KeyHook listener class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | public class KeyPressEventArgs : EventArgs { public KeyPressEventArgs( Keys ModifierKeys, int KeyCode ) { this.ModifierKeys = ModifierKeys; this.KeyCode = KeyCode; } public readonly Keys ModifierKeys; public readonly int KeyCode; } public class KeyLoggerListener { public delegate void KeyPressHandler( object inputListener, KeyPressEventArgs KeyPressInfo ); public event KeyPressHandler OnKeyPress; [DllImport( "user32.dll" )] public static extern int GetAsyncKeyState( long vKey ); public void Run() { Thread t = new Thread( new ThreadStart( Listener ) ); t.IsBackground = true; t.Start(); } private void Listener() { while ( true ) { Thread.Sleep( 10 ); int i = 0; for ( i = 1; i < Byte.MaxValue; i++ ) { if ( GetAsyncKeyState( i ) == Int16.MinValue + 1 ) { KeyPressEventArgs KeyPressInfo = new KeyPressEventArgs( Control.ModifierKeys, i ); if ( OnKeyPress != null ) { OnKeyPress( this, KeyPressInfo ); } } } } } } |
Ok. Now, run it on Form_Load():
1 2 3 | KeyLoggerListener keylogger = new KeyLoggerListener(); keylogger.OnKeyPress += new KeyLogger.KeyLoggerListener.KeyPressHandler( keylogger_OnKeyPress ); keylogger.Run(); |
and create OkKeyPress event:
1 2 3 4 5 6 7 8 9 10 11 12 13 | private void keylogger_OnKeyPress( object inputListener, KeyPressEventArgs KeyPressInfo ) { char digit = Convert.ToChar( KeyPressInfo.KeyCode ); switch ( KeyPressInfo.ModifierKeys ) { case Keys.Alt: ReleaseCapture(); SendMessage( handle, 0xa1, 0x2, 0 ); break; default: break; } } |
It’s all!
When the ALT key is detected, the program will launch a SendMessage( handle, 0xa1, 0×2, 0 ) passing the control (handle) of the foreground window and… you can move it!
Oh, by the way, you can also move an opened Windows’ Start Menu! You don’t believe me? Watch this!!!

happy summer.
Un .sh come promemoria per macchine a 64bit, non si sa mai…
Versione OPTIMIZED:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Clean everything if test -d optimized; then \ cd optimized; \ make distclean; \ cd ..; \ fi; # Do autoconf & friends make -f Makefile.cvs mkdir optimized cd optimized # Configure for debug build export CXXFLAGS="-O2 -Wno-deprecated -Wall -g0" ../configure # Build make |
Versione DEBUG:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Clean everything if test -d debug; then \ cd debug; \ make distclean; \ cd ..; \ fi; # Do autoconf & friends make -f Makefile.cvs mkdir debug cd debug # Configure for debug build export CXXFLAGS="-O0 -Wno-deprecated -g3" ../configure # Build make |
yep.
| L | M | M | G | V | S | D |
|---|---|---|---|---|---|---|
| « ago | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||