Skip to content

Instantly share code, notes, and snippets.

@mohamnag
mohamnag / gist:1f594d9e1119605fa409
Created January 20, 2014 22:10
This function sends GCM push messages using cakephp's HttpSocket
public function sendPush($token, $collapseKey, $title, $messageText) {
if(!is_array($token)) {
$token = array($token);
}
App::uses('HttpSocket', 'Network/Http');
$HttpSocket = new HttpSocket();
$data = array(
'registration_ids' => $token,
@mohamnag
mohamnag / gist:47ce52e2d90ff01f17a2
Created November 3, 2014 09:15
Facebook share button without using official JavaScript plugin
<style>
.fb-share-button {
background: #4c69ba;
background: -webkit-gradient(linear, center top, center bottom, from(#4c69ba), to(#3b55a0));
background: -webkit-linear-gradient(#4c69ba, #3b55a0);
background: gradient(linear, center top, center bottom, from(#4c69ba), to(#3b55a0));
background: linear-gradient(#4c69ba, #3b55a0);
border: none;
-webkit-border-radius: 2px;
color: #fff;
@mohamnag
mohamnag / gist:c570f78d47351b182b1c
Created November 3, 2014 09:36
Tweeter share button without the official JavaScript plugin
<style>
.tw-share-button {
white-space: nowrap;
position: relative;
background-color: #eee;
background-image: -webkit-linear-gradient(#fff,#dedede);
background-image: linear-gradient(#fff,#dedede);
border: #ccc solid 1px;
border-radius: 3px;
color: #333;
@mohamnag
mohamnag / gist:fc05ea86d725b49d6077
Last active August 29, 2015 14:08
CSS to over come the select arrow display and show a customized element
.custom-select {
-webkit-appearance: none;
-moz-appearance: window;
appearance: none;
border-radius: 0;
background: transparent;
text-indent: 0.01px;
text-overflow: '';
@mohamnag
mohamnag / mixins.scss
Created November 27, 2014 13:12
using a font for icons
/*
This adds the desired character as an overlayed icon vertically and horizontally
centered on the element.
This uses the :after pseudo element so this element is not usable afterwards.
*/
@mixin fontIcon($font, $char, $size) {
&:after {
// character related to the desired icon
content: $char;
@mohamnag
mohamnag / mixins.scss
Created December 16, 2014 11:51
CSS3 show and hide animation
$veryBigWidth: 100rem;
$veryBigHeight: 100rem;
@mixin transition-hide {
transition: opacity 0.5s ease;
visibility: hidden;
opacity: 0;
max-height: 0;
max-width: 0;
@mohamnag
mohamnag / .bash_profile
Created December 31, 2014 18:24
My preferred bash prompt
export PS1="\\[$(tput setaf 6)\\]\\u:\\w #\\[$(tput sgr0)\\] "
@mohamnag
mohamnag / mixin.scss
Last active August 29, 2015 14:13
Adds a shadowy border on top of the element using the :before pseudo element, you may apply the last three lines directly to the element itself if you dont need additional background on the same element.
@mixin shadow-border-top($size: 10px) {
&:before {
content: "";
width: 100%;
height: $size;
display: block;
top: 0;
position: absolute;
background: linear-gradient(to top, transparent 0%, rgba(0, 0, 0, 0.09) 75%, white 88%, white 100%) no-repeat;
background-position: 0 -$size / 2;
@mohamnag
mohamnag / gist:4564144427df886593ed
Created February 26, 2015 09:26
s3cmd sync necessary user policy, this policy should be attached to user in IAM console
{
"Statement": [
{
"Action": [
"s3:ListAllMyBuckets"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::*"
},
{
@mohamnag
mohamnag / run.sh
Created March 17, 2015 10:12
swap file on aws micro instances
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=2048
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
echo /var/swapfile none swap defaults 0 0 | sudo tee -a /etc/fstab
sudo swapon -a