Statuses

Ubuntu Wins again

In General on August 13, 2012 by patrellery

Ubuntu Wins again,

Would you spend money on something that has bugs? No of course, here’s a story about a smart school teacher.

http://ifixit.org/3001/how-one-teacher-built-a-computer-lab-for-free/

Articles

what is really css3 box-shadow

In CSS3 on June 17, 2012 by patrellery Tagged:

most people still create crappy images for shadows. so to make it simple, and easy let’s just use the shadow properties:

div
{
box-shadow: 10px 10px 5px #888888;
}

so what this really means:
Read More »

Articles

Ident Code in Textarea

In jQuery on December 21, 2011 by patrellery Tagged: ,

How many times you wanted to use the tab in your textarea ?

I’m sure a lot!

Here’s a very simple jQuery code that will allow to use the TAB key in a textarea!


$(document).ready(function(e) {

// Using the
$('textarea.tab').keydown(function(e) {
if(e.keyCode == 9) {
var start = $(this).get(0).selectionStart;
$(this).val($(this).val().substring(0, start) + "\t" + $(this).val().substring($(this).get(0).selectionEnd));
$(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 1;
return false;
}
});

// Using Spaces
$('textarea.space').keydown(function(e) {
if(e.keyCode == 9) {
var start = $(this).get(0).selectionStart;
$(this).val($(this).val().substring(0, start) + " " + $(this).val().substring($(this).get(0).selectionEnd));
$(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 4;
return false;
}
});
});

View the full article at www.bookofzeus.com/articles/indent-code-in-textarea-using-jquery/

Articles

Custom @Font-Face in CSS3

In CSS3 on November 24, 2011 by patrellery Tagged:

Here’s a quick tip on how to display fonts in your page:

Download the font: http://www.fontsquirrel.com/fonts/Hattori-Hanzo

And use this code in your CSS file:

@font-face {
font-family: 'HattoriHanzoLight';
src: url('hattori_hanzo.otf') format('opentype');
font-weight: normal;
font-style: normal;
}

Then in your HTML:

some content!

Articles

Encryption & decryption with AES/ECB/PKCS7Padding in Java

In Java on November 20, 2011 by patrellery Tagged: ,

If you ever wonder how to encrypt and decrypt AES/ECB/PKCS7Padding in Java, here’S a little script that you need to use:

Read More »

Articles

RSA Encryption-Decryption in iphone

In iPhone on October 17, 2011 by patrellery

#import
#import
#import

@interface NSString (NSStringAdditions)

+ (NSString *) base64StringFromData:(NSData *)data length:(int)length;
- (NSString *) base64StringWithHMACSHA1Digest:(NSString *)secretKey;

@end

-------------------------------------------

#import "NSStringAdditions.h"

static char base64EncodingTable[64] = {
'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', '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', '+', '/'
};

@implementation NSString (NSStringAdditions)

- (NSString *) base64StringWithHMACSHA1Digest:(NSString *)secretKey {
unsigned char digest[CC_SHA1_DIGEST_LENGTH];
char *keyCharPtr = strdup([secretKey UTF8String]);
char *dataCharPtr = strdup([self UTF8String]);

CCHmacContext hctx;
CCHmacInit(&hctx, kCCHmacAlgSHA1, keyCharPtr, strlen(keyCharPtr));
CCHmacUpdate(&hctx, dataCharPtr, strlen(dataCharPtr));
CCHmacFinal(&hctx, digest);
NSData *encryptedStringData = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];

free(keyCharPtr);
free(dataCharPtr);

return [NSString base64StringFromData:encryptedStringData length:[encryptedStringData length]];
}

+ (NSString *) base64StringFromData: (NSData *)data length: (int)length {
unsigned long ixtext, lentext;
long ctremaining;
unsigned char input[3], output[4];
short i, charsonline = 0, ctcopy;
const unsigned char *raw;
NSMutableString *result;

lentext = [data length];
if (lentext < 1)
return @"";
result = [NSMutableString stringWithCapacity: lentext];
raw = [data bytes];
ixtext = 0;

while (true) {
ctremaining = lentext - ixtext;
if (ctremaining <= 0)
break;
for (i = 0; i < 3; i++) {
unsigned long ix = ixtext + i;
if (ix > 2;
output[1] = ((input[0] & 0x03) <> 4);
output[2] = ((input[1] & 0x0F) <> 6);
output[3] = input[2] & 0x3F;
ctcopy = 4;

switch (ctremaining) {
case 1:
ctcopy = 2;
break;
case 2:
ctcopy = 3;
break;
}

for (i = 0; i < ctcopy; i++)
[result appendString: [NSString stringWithFormat: @"%c", base64EncodingTable[output[i]]]];

for (i = ctcopy; i 0) && (charsonline >= length))
charsonline = 0;

return result;
}

@end

Articles

Convert XML Object to Array in PHP

In PHP on October 15, 2011 by patrellery

Here’s a very simple way to convert an XML Object to an array in PHP.

$string = '
<user>
  <id>1234</id>
  <username>root</username>
  <password>helloWorld</password>
  <access>
    <admin>0</admin>
    <write>1</write>
    <read>1</read>
  </access>
  <messages>
    <message>Message 1</message>
    <message>Message 1</message>
  </messages>
</user>';

$xml = json_decode(json_encode((array)simplexml_load_string($string)), TRUE);

easy no?

Follow

Get every new post delivered to your Inbox.