Skip to content

Instantly share code, notes, and snippets.

View mohamedrez's full-sized avatar
🎯
Focusing

Mohamed mohamedrez

🎯
Focusing
View GitHub Profile

Objects

To create a new object, use the new keyword followed by a call to a constructor function. Javascript provides the Object() constructor out-of-the-box:

var toilet = new Object();

Properties

Once you have an object, you can set and get properties on it, like this:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
@mohamedrez
mohamedrez / newdrupalsite
Last active March 9, 2016 16:47 — forked from tsi/newsite
New drupal site
#!/bin/bash
# This script creates virtual hosts and prepares your drupal directory.
# you should put it under /usr/local/bin/
# and run it with sudo newvhost
# Set the path to your localhost
www=/var/www
echo "Enter directory name under $www"
@mohamedrez
mohamedrez / default.vcl
Created July 27, 2014 14:50
Varnish conf for Maaal
backend default {
.host = "127.0.0.1";
.port = "8080";
}
# Drop any cookies sent to Wordpress.
sub vcl_recv {
if (!(req.url ~ "wp-(login|admin)")) {
unset req.http.cookie;
}
@mohamedrez
mohamedrez / wp-medata.php
Last active August 29, 2015 14:04
wp: select all metadata values
<?php
function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {
global $wpdb;
if( empty( $key ) )
return;
$r = $wpdb->get_col( $wpdb->prepare( "
SELECT pm.meta_value FROM {$wpdb->postmeta} pm
<?php
/**
* Logs error to file
*
* @uses `error_log` function to log on file
*
* @param string $error message of the error
* @param string $type type of the error message
*/
function log_error( $error, $type = 'error' ) {
@mohamedrez
mohamedrez / gist:f297e69e19c7c69b7c61
Created August 17, 2014 10:22
php: download a file
<?php
file_put_contents("nameofthefile.ext", fopen("http://url.ext", 'r'));
echo("downloaded");
?>
@mohamedrez
mohamedrez / WP: Bulk update custom field using a sql query
Last active August 29, 2015 14:06
WP: Bulk update custom field using a sql query
<?php
$ids = $wpdb->get_results("SELECT id FROM wp_4_posts WHERE post_type = 'post' LIMIT 0 , 300");
foreach($ids as $id){
update_post_meta($id->id, 'post_country', 'ksa');
}
@mohamedrez
mohamedrez / mymodule.info
Last active August 29, 2015 14:08 — forked from juampynr/mymodule.info
Drupal views handler
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_handlername.inc
@mohamedrez
mohamedrez / d7_admin_form.php
Created July 22, 2015 09:48
D7 Form administration form
/**
* Implements hook_form().
* Admin form stripe configuration
*/
function mymodule_configuration_form($form, &$form_state) {
$form['mymodule_mode'] = array(
'#type' => 'select',
'#title' => t('Mode'),