Skip to content

Instantly share code, notes, and snippets.

View AFelipeTrujillo's full-sized avatar

Andrés Felipe Trujillo AFelipeTrujillo

View GitHub Profile
@AFelipeTrujillo
AFelipeTrujillo / VariablesClass.cs
Last active August 29, 2015 14:24
CSharp For Beginner - Assignment Variables
using System;
namespace CSharpBeginner
{
public class VariablesClass
{
public VariablesClass ()
{
}
@AFelipeTrujillo
AFelipeTrujillo / ConditionalStatementClass.cs
Created July 15, 2015 06:26
The if Decision Statement and the Conditional Operator with C#
using System;
namespace CSharpBeginner
{
public class ConditionalStatementClass
{
public ConditionalStatementClass ()
{
}
@AFelipeTrujillo
AFelipeTrujillo / InheritanceClass.cs
Created July 16, 2015 03:50
Understanding the Inheritance in C-Sharp (C#)
using System;
namespace CSharpBeginner
{
public class InheritanceClass
{
public InheritanceClass ()
{
}
@AFelipeTrujillo
AFelipeTrujillo / UtilidadesJavascript.js
Created July 16, 2015 22:43
Diferentes funciones útiles para Javascript
//Pull an element from array by its name
//Eliminar un elemento desde un array por el nombre
function pullByName(name,array){
var i = array.indexOf(name);
if(i != -1) {
array.splice(i, 1);
}
}
@AFelipeTrujillo
AFelipeTrujillo / parseInt.js
Created August 18, 2015 14:26
To parse an integer in javascript with jQuery
var sNum = "12314";
var num = parseInt(sNum.match(/\d+/)[0]);
console.log(num);
@AFelipeTrujillo
AFelipeTrujillo / SprintfJavascript.js
Created August 22, 2015 14:48
How to create a Sprrint in Javascript?
var text = 'Hello {first_name} {last_name}';
var firstName = 'Felipe';
var lastName = 'Trujillo';
console.log(text.replace(/{first_name}/g, firstName).replace(/{last_name}/g),lastName);
@AFelipeTrujillo
AFelipeTrujillo / HeaderJson4PHP.php
Last active September 11, 2015 22:43
Create a json response with 500 error
header('Content-Type: application/json; charset=utf-8', true, 500);
print json_encode(array('hasErrorCreate' => true, 'data' => 1));
@AFelipeTrujillo
AFelipeTrujillo / AuditActiveRecord.php
Last active October 20, 2015 22:48
Audit class with Yii2
<?php
namespace app\lib;
use app\lib\Log;
/**
* @author Andres Felipe Trujillo
*/
class AuditActiveRecord extends \yii\db\ActiveRecord
{
@AFelipeTrujillo
AFelipeTrujillo / Picture.cshtml
Created October 29, 2015 21:03
How to create a thumbnail image with C-Sharp (C#)
@model Project.Models.PictureModel
@{
ViewBag.Title = "PictureUpload";
}
<h2>PictureUpload</h2>
@using (Html.BeginForm("PictureUpload", "Controller", FormMethod.Post, new { enctype = "multipart/form-data" }))
@AFelipeTrujillo
AFelipeTrujillo / addAttendee.php
Last active February 26, 2024 21:28
Use Google Calendar API
<?php
include_once 'google-api-php-client/vendor/autoload.php';
$client = new Google_Client();
$application_creds = 'service-account-credentials.json';
$credentials_file = file_exists($application_creds) ? $application_creds : false;
define("SCOPE",Google_Service_Calendar::CALENDAR);
define("APP_NAME","Google Calendar API PHP");