Skip to content

Instantly share code, notes, and snippets.

View ajaimesv's full-sized avatar
💭
Biking

Andres Jaimes ajaimesv

💭
Biking
View GitHub Profile
@ajaimesv
ajaimesv / docker-gitlab.sh
Last active May 27, 2016 17:55
Docker - GitLab : Start a GitLab instance in docker
#!/bin/bash
# Start a GitLab instance in docker.
# Services will be available on ports 9000, 9001 and 9002.
sudo docker run --detach \
--hostname localhost \
--publish 9000:80 --publish 9001:443 --publish 9002:22 \
--name gitlab \
--restart always \
@ajaimesv
ajaimesv / gist:8628548565e432e722bd2fbf968c9d17
Created May 27, 2016 17:57
mongodb : Import a batch of json docs into mongodb.
# Import json docs into mongodb:
mongoimport --db mydb --collection users --file users.json
# Sample file to import:
{_id:NumberInt(1), title:"Text"}
{_id:NumberInt(2), title:"Text"}
{_id:NumberInt(3), title:"Text"}
@ajaimesv
ajaimesv / gist:b9008614b90fd3d5f24a32808218c0cd
Created May 27, 2016 17:57
mongodb : Get a random record from a collection with mongodb 3
db.coll.aggregate(
{ $sample: { size: 1 } }
)
@ajaimesv
ajaimesv / responsive-youtube.html
Created December 5, 2016 22:02
Responsive YouTube videos
<div class="video-container">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ZB-jmlA3veo" frameborder="0" allowfullscreen></iframe>
</div>
<style>
.video-container {
position:relative;
padding-bottom:56.25%;
padding-top:30px;
height:0;
@ajaimesv
ajaimesv / razor-snippets.cshtml
Created December 5, 2016 22:03
Razor snippets
@{Layout = "~/Views/Shared/_Layout.cshtml";}
@Url.Content("~/Content/Site.css")
@Url.Content("~/Scripts/jquery-1.5.1.min.js")
@Url.Action("Index", "Sample")
@RenderBody()
@Html.Partial("~/Views/...")
@{
var price = 20;
var weekday = DateTime.Now.DayOfWeek;
@ajaimesv
ajaimesv / hex.java
Last active December 5, 2016 22:06
How to convert File to Hex in Java
/*
* How to convert File to Hex in Java
* https://www.mkyong.com/java/how-to-convert-file-to-hex-in-java/
*/
package sqltracereader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@ajaimesv
ajaimesv / Metadata.java
Created December 5, 2016 22:09
Get table's columns and types
package javaapplication2;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
// The following code will automatically send Basic Auth info in all requests.
// Create the basic auth info
HttpAuthenticationFeature feature =
HttpAuthenticationFeature.basic(
"user@domain.com", // or just "user"
"password");
// create the client
@ajaimesv
ajaimesv / swap.sh
Created January 25, 2017 17:11
Adding swap memory to a running amazon instance
# Add swap memory to a running amazon instance
# Choose your swap size, in this case 4096M (4G)
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=4096
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1
# Add the following line to /etc/fstab to enable swap at boot:
@ajaimesv
ajaimesv / docker-compose.yml
Created February 3, 2017 22:01
docker-compose for nginx
# Sample file for nginx
# docker-compose up -d
# docker-compose up -d --no-recreate
# docker-compose stop
# docker-compose rm -f
web:
image: nginx:alpine
container_name: nginx