Skip to content

Instantly share code, notes, and snippets.

View Luis-Palacios's full-sized avatar
🎯
Focusing

Luis Palacios Luis-Palacios

🎯
Focusing
View GitHub Profile
@Luis-Palacios
Luis-Palacios / Environment Variable Connection String
Created January 5, 2015 04:10
Chossing connection string according to Environment Variable
private static string GetConnectionString()
{
var environmentVariable = Environment.GetEnvironmentVariable("FunctionalTests");
return environmentVariable == null
? ConfigurationManager.ConnectionStrings["SchoolContext"].ConnectionString
: ConfigurationManager.ConnectionStrings["SchoolContext-FunctionalTests"].ConnectionString;
}
//Si esta setiado el valor de la variable de entorno FunctionalTests usa la base de datos para la prueba
@Luis-Palacios
Luis-Palacios / Django-postgres configuration example
Created June 1, 2015 18:38
An example to show the configuration for database with django and postgres
import dj_database_url
DATABASES= {'default':dj_database_url.config(
default='postgres://DbUser:strongPasword@yourhost/dbName'
)}
@Luis-Palacios
Luis-Palacios / Nginx gzip settings
Created June 9, 2015 04:33
Nginx gzip settings
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
gzip_comp_level 6;
# gzip_buffers 16 8k;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
@Luis-Palacios
Luis-Palacios / djangofor.xml
Created July 21, 2015 05:25
Example of snippet for django template
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>form</Title>
<Author>Microsoft Corporation</Author>
<Shortcut>form</Shortcut>
<Description>Markup snippet for a HTML form</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
@Luis-Palacios
Luis-Palacios / 1.python_dependencies.bash
Last active October 8, 2015 03:49
Installing and configuring ubuntu server for django application
#You will probably need root privilegies so use sudo before any command or login as root
#Lets update everything before we go
apt-get update
apt-get upgrade
#Now for the python dependencies
#You need all of this in order for python to compile with full power
@Luis-Palacios
Luis-Palacios / regex.js
Created December 10, 2015 14:21
Regex Url Validator (Escaped)
/(((https?:\/\/+)(?:www\.)[A-Za-z0-9.-]+\.+.{2,4}|(?:^www\.)[A-Za-z0-9.-]+\.+.{2,4})((?:\/[\+~%\/.\w-_]*)?(\?+(?:[-\+=&;%@.\w_]*))?(#+(?:[\w]*))?)?)$/
@Luis-Palacios
Luis-Palacios / PropertyStub.snippet
Last active December 29, 2015 00:01
PropertyStub snippet for C# that uses fullprop snippet to implement interface properties
<?xml version="1.0" encoding="utf-8"?>
<!-- Credits go to: http://codeimpossible.com/2010/11/29/Make-Implement-Interface-use-auto-properties/ -->
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Property Stub</Title>
<Description>Snippet for generating property stub</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Refactoring</SnippetType>
@Luis-Palacios
Luis-Palacios / back.bash
Last active April 18, 2016 17:38
Backing up data from a server
tar -zcvf media.tar.gz media/
as root user
pg_dump -h localhost -U Dbuser DbName > /path/fileName.sql
from psqlconsle
\i E:/file.sql
GRANT SELECT ON ALL TABLES IN SCHEMA public TO myuser;
@Luis-Palacios
Luis-Palacios / Controller.cs
Created May 11, 2016 20:47
Created Method for ASP.Net Web api
return CreatedAtRoute("DefaultApi", new { id = test.TestId }, test);
string url = Url.Link("DefaultApi", new { id = test.TestId });
return Created(url, test);
//For Route Attirbutes
[Route("api/books/{id}", Name="GetBookById")]
public BookDto GetBook(int id)
{
// Implementation not shown...
@Luis-Palacios
Luis-Palacios / dependencies
Created March 5, 2017 02:51
PHP Dependencies
http://askubuntu.com/questions/756181/installing-php-5-6-on-xenial-16-04
apt-get install php5.6-pgsql
install composer
composer install