Skip to content

Instantly share code, notes, and snippets.

View timbergus's full-sized avatar

Gustavo Muñoz timbergus

View GitHub Profile
@timbergus
timbergus / gist:4673224
Created January 30, 2013 13:14
Snippet to create a jQuery AJAX Synchronous call using POST.
$.ajax({
type: 'POST',
url: 'Path to the file',
async: false,
data:
{
dataName1: value1,
dataName2: value2,
dataName3: value3
},
@timbergus
timbergus / gist:4687430
Created January 31, 2013 22:51
This code initialize the different sizes of the iPhone/iPad screens to do something depending on which device we are using.
UIDevice *device = [[UIDevice alloc] init];
if ([device.model isEqualToString:@"iPhone"] || [device.model isEqualToString:@"iPhone Simulator"]) {
if ([[UIScreen mainScreen] bounds].size.height == 480) {
// Do something with the iPhone
}
if ([[UIScreen mainScreen] bounds].size.height == 568) {
// Do something with the iPhone5
@timbergus
timbergus / gist:4714227
Last active November 24, 2022 08:41
Working with AJAX (jQuery and Javascript) and functions in PHP. This helps to reduce the number of files we usually need, to execute PHP functions from AJAX. With this we don't need one PHP file per function.
/* Javascript jQuery AJAX functions file */
function functionName(functionName, functionParameters)
{
$.ajax({
type: 'POST',
url: 'ourFunctionsFile.php',
async: false,
data:
{
@timbergus
timbergus / server.js
Created June 19, 2013 07:43
Basic node.js server without express, returning HTML contents instead plain text.
var http = require('http');
var port = 8080;
var server = http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/html'});
response.write('<h1>Hello World!</h1>');
response.end();
});
server.listen(port, function() {
@timbergus
timbergus / index.html
Last active June 2, 2024 15:10
Basic HTML5 "Hello World!" document structure.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello World! Site Title</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
@timbergus
timbergus / server.js
Created June 22, 2013 14:14
This is the basic structure to create a node server with express.
var express = require('express');
var app = express();
app.get('/', function(request, response) {
response.send('<h1>Hello World!</h1>');
});
var port = process.env.PORT || 1337;
app.listen(port, function() {
@timbergus
timbergus / index.html
Created August 21, 2013 11:05
This is a basic angular code example from http://angularjs.org/. It shows how to build a simple editable field through a text input.
<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script>
</head>
<body>
<div>
<label>Name:</label>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
<hr>
@timbergus
timbergus / server.js
Created October 24, 2013 07:01
Basic Node.js server with Express.
var express = require("express");
var app = express();
app.use(express.logger());
app.get('/', function(request, response)
{
response.send('Hello World!');
});
var port = process.env.PORT || 5000;
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
@timbergus
timbergus / gruntfile.js
Created January 31, 2015 18:27
Basic gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
});
grunt.registerTask('default', []);
};