Skip to content

Instantly share code, notes, and snippets.

View alihalabyah's full-sized avatar
🎯
Focusing

Ali Halabyah alihalabyah

🎯
Focusing
View GitHub Profile
@alihalabyah
alihalabyah / gist:d831d1fbb89e2cf87fef
Created April 8, 2015 10:19
Github mirror Bitbucket or vice versa
git remote add bitbucket /url/to/am/empty/bitbucket/repo
git push --mirror bitbucket
# Add new user group
groupadd sftpusers
# Add new user set the directory, the main role and the user name
useradd -g sftpusers -d /dir -s /sbin/nologin username
# Make sure the user can perform SSH login
usermod username -s /sbin/nologin
# Make sure the user has been added
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@alihalabyah
alihalabyah / designer.html
Last active August 29, 2015 14:08
designer
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
@alihalabyah
alihalabyah / designer.html
Last active August 29, 2015 14:08
designer
<link rel="import" href="../core-ajax/core-ajax.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
function countProperties(obj) {
var prop;
var propCount = 0;
for (prop in obj) {
propCount++;
}
return propCount;
}

Writing better python code


Swapping variables

Bad code

@alihalabyah
alihalabyah / gist:b674bf680e3ec2d5dbfd
Created September 13, 2014 16:34
Product info sample response
array(50) {
["product_id"]=>
string(3) "184"
["description"]=>
string(454) "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam bibendum nunc dictum, elementum tortor at, aliquet odio. Suspendisse accumsan semper leo non ornare. Quisque lacinia quis orci id ultricies. Praesent interdum urna vitae tempus vulputate. In vel lobortis mauris. Cras diam mi, scelerisque quis interdum eu, congue in elit. Mauris tincidunt convallis nulla, quis mollis nisi luctus nec. Donec risus enim, congue ac sodales et, aliquam eget justo"
["image"]=>
string(134) "http://progress.devshopgo.me/media/catalog/product/cache/4/image/265x/9df78eab33525d08d6e5fb8d27136e95/s/h/shutterstock_96360692_1.jpg"
["internal"]=>
array(1) {
["currency"]=>
@alihalabyah
alihalabyah / gist:1e01721ea007b52cbe3a
Created September 7, 2014 09:22
convert image to base64
/**
* Convert an image
* to a base64 string
* @param {String} url
* @param {Function} callback
* @param {String} [outputFormat=image/png]
*/
function convertImgToBase64(url, callback, outputFormat){
var canvas = document.createElement('CANVAS'),
ctx = canvas.getContext('2d'),
@alihalabyah
alihalabyah / gist:4d39106eaa8fe48b481d
Created July 8, 2014 12:40
Clear Magento cart and quote items
<?php
// Clear Magento cart and quote items
$cart = Mage::getModel('checkout/cart');
$cart->truncate()->save(); // remove all active items in cart page
$cart->init();
$session= Mage::getSingleton('checkout/session');
$quote = $session->getQuote();
$cart = Mage::getModel('checkout/cart');