Skip to content

Instantly share code, notes, and snippets.

View alihalabyah's full-sized avatar
🎯
Focusing

Ali Halabyah alihalabyah

🎯
Focusing
View GitHub Profile
# This configuration is what is provided by PageCache by Varnish for Magento module:
# http://www.magentocommerce.com/magento-connect/pagecache-powered-by-varnish.html
# default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "80";
}
# admin backend with longer timeout values. Set this to the same IP & port as your default server.
@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: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"]=>

Writing better python code


Swapping variables

Bad code

function countProperties(obj) {
var prop;
var propCount = 0;
for (prop in obj) {
propCount++;
}
return propCount;
}
@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">
@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">
<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%;
# 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
@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