Skip to content

Instantly share code, notes, and snippets.

@karmiphuc
karmiphuc / dung-huong-het-phuoc-bao.md
Created August 28, 2015 03:21
Đừng hưởng hết phước báo - trích sách

Bạn đang nghèo ư ..? Bạn đang kém phước. Bạn muốn thay đổi số phận..? Bạn đang giàu có...? Bạn có nhiều phước báu. Bạn có giàu có suốt đời..?

Có 1 lời khuyên cho bạn :

Bạn đừng hưởng hết phước báu, bạn hãy tích phước và kiệm phước..!!!Tôi có quen một "thầy bói" rất nổi tiếng. Thầy nói với tôi, trong mấy chục năm xem số cho người:

  • Phàm những ai giàu sớm thì thường chết sớm hoặc cuối đời không đâu vào đâu cả. Khi đó tôi không hiểu vì sao, hỏi thầy, thầy cười bảo : Trẻ nó sướng, cái gì trên đời nó cũng hưởng hết rồi mà không tạo ra được phước mới, còn gì nữa mà không chết sớm hay khổ cực cuối đời.

Sau này tôi mới nghiệm ra, quả vậy, đàn ông có tiền thì thường sa đọa, nhất là những người trẻ. Vì có tiền trong tay khi còn trẻ, đàn ông thường tìm đến rượu và gái. Tuyệt đối không nằm ngoài hai thứ này, chúng nó luôn đi cùng với nhau, gái rượu rượu gái, 1 đôi bạn thân. Rượu và gái không chỉ cướp đi sức khỏe mà nó còn cướp đi cả hạnh phúc gia đình và sự nghiệp đang thăng tiến. Thử nhìn lại xem bao nhiêu quan

{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_bottom": 1,
"caret_extra_top": 1,
"caret_extra_width": 2,
"close_windows_when_empty": false,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"default_line_ending": "unix",
"detect_indentation": false,
@karmiphuc
karmiphuc / encrypt_decrypt_with_mcrypt.php
Created July 13, 2015 04:52
PHP Encryption/Decryption done right (PHP 5.3+)
<?php
/**
* Returns an encrypted & utf8-encoded
*/
function encrypt($pure_string) {
$encryption_key = 'random_string_here_as_private_key';
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $encryption_key, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
return $encrypted_string;
@karmiphuc
karmiphuc / .gitconfig
Last active August 29, 2015 14:24
Personal .gitconfig (global)
[user]
name = KarmiPhuc
email = si.gn.up.kp@gmail.com
[core]
autocrlf = true
editor = npp
[alias]
today = log --since=midnight --author='KarmiPhuc' --oneline
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
s = status

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

#!/bin/sh
# Credentials for a MySQL user with PROCESS, SUPER permissions
USERNAME=
PASSWORD=
# MySQL Server location
HOST=127.0.0.1
PORT=3306
// Helper functions
/*
The next function we will use for inheritance is the inheritPrototype function.
This function succinctly implements the parasitic combination inheritance for us.
We pass in the parent object (or Super Class) and the child object (or Sub Class),
and the function does the parasitic combination inheritance:
makes the child object inherits from the parent object.
*/
function inheritPrototype(childObject, parentObject) {
// As discussed above, we use the Crockford’s method to copy the properties and methods from the parentObject onto the childObject
SELECT `sender_user_id`, name, COUNT(*) as `num_users_contacted`, COUNT(id) as `num_users_responded` FROM
(SELECT DISTINCT name,`owner_user_id`,`sender_user_id`,`recipient_user_id`,T.* FROM `internal_messages` im1
LEFT JOIN (
SELECT DISTINCT `sender_user_id` as `sui`,`recipient_user_id` as `rui`, `id` FROM `internal_messages` as `im2`
WHERE MOD(`im2`.id,2) = 1
GROUP BY `sui`,`rui`
) AS T
ON T.`sui` = `im1`.`recipient_user_id` AND T.`rui` = `im1`.`sender_user_id`, users as u
WHERE MOD(`im1`.id,2) = 1 AND (`im1`.id <= T.id OR T.id is NULL)
AND u.id = im1.owner_user_id) AS X
SELECT u.id, u.name,COUNT(*) as `total_cold_inquiries_received` FROM `internal_messages` im1
LEFT JOIN (
SELECT DISTINCT `sender_user_id` as `sui`,`recipient_user_id` as `rui`, `id` FROM `internal_messages` as `im2`
WHERE MOD(`im2`.id,2) = 1
GROUP BY `sui`,`rui`
) AS T
ON T.`sui` = `im1`.`recipient_user_id` AND T.`rui` = `im1`.`sender_user_id`, users as u
WHERE MOD(`im1`.id,2) = 1 AND (`im1`.id <= T.id OR T.id is NULL) AND u.id = im1.recipient_user_id
GROUP BY u.name
ORDER BY recipient_user_id