Skip to content

Instantly share code, notes, and snippets.

View elvikito's full-sized avatar
:octocat:
Working from home

Elvis Ramirez elvikito

:octocat:
Working from home
  • @code.bo
  • Bolivia - Cochabamba.
View GitHub Profile
@elvikito
elvikito / env.py
Created October 20, 2017 15:18
virtual env with python.
virtualenv --no-site-packages --python=/usr/bin/python2.7 env
@elvikito
elvikito / timeinterval.ts
Created August 29, 2017 16:49
Angular 2 conjunto de llamadas a setInterval (), tira undefined inyección de dependencia.
this.interval = setInterval(() => {
this.fucntion()...;
}, 1000);
ngOnDestroy() {
if (this.interval) { clearInterval(this.interval); }
}
@elvikito
elvikito / docker_comands.txt
Last active June 18, 2021 12:26 — forked from dvdasari/gist:439ce7c1814c2392c3bf
docker commands
1. Create new container
a) docker run -i -t ubuntu /bin/bash
b) docker run --name rails_dev_container -i -t ubuntu ubuntu /bin/bash
The command line flags - i -t provide an interactive shell in the new container
2. Show running docker containers ==> docker ps
3. Show list of current containers ==>
a) docker ps -a (Show all containers, both stopped and running)
b) docker ps -n x (shows the last x containers, running or stopped, ex: docker ps -n 5)
#!/bin/bash
docker ps --all | grep -v 'CONTAINER' | awk '{ print $1 }' | xargs docker rm
@elvikito
elvikito / models.py
Created July 31, 2017 14:05
Custom Manager With Chainable QuerySets
# Now you can use it just like any other QuerySet method:
# Document.objects.pdfs().smaller_than(1000).exclude(name='Article').order_by('name')
# If you are only defining custom QuerySets in the Manager,
# you can simply extend the models.QuerySet and in the model set the manager as objects = DocumentQuerySet.as_manager()
class DocumentQuerySet(models.QuerySet):
def pdfs(self):
return self.filter(file_type='pdf')
def smaller_than(self, size):
@elvikito
elvikito / emitter.service.ts
Created July 24, 2017 21:29
Angular2 Communicating between sibling components
import {Injectable, EventEmitter} from 'angular2/core';
@Injectable()
export class EmitterService {
private static _emitters: { [ID: string]: EventEmitter<any> } = {};
static get(ID: string): EventEmitter<any> {
if (!this._emitters[ID])
this._emitters[ID] = new EventEmitter();
@elvikito
elvikito / new_gist_file.sh
Created April 21, 2017 02:26 — forked from un1ko85/new_gist_file.sh
Starting and stopping NginX / MySQL / PHP-FPM on Mac OS X
#! /bin/bash
MYSQL="/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper"
NGINX="/opt/local/sbin/nginx"
PHPFPM="/opt/local/sbin/php-fpm"
PIDPATH="/opt/local/var/run"
MEMCACHED="/opt/local/bin/memcached -m 24 -P /opt/local/var/run/memcached.pid -u root"
if [ $1 = "start" ]; then
sudo $MYSQL start
echo "Starting php-fpm ..."
cacheBust: {
taskName: {
options: {
algorithm: 'sha1',
deleteOriginals: true,
length: 32,
baseDir : "frontend/",
assets: [
//'home/home.css',
//'app-less.css',
class FileDownloadView(APIView):
permission_classes = (IsAuthenticated,)
def get(self, request, pk):
# trade = Trade.objects.filter(account__portfolio=pk).values()
trade = Trade.objects.filter(account__portfolio=pk)
for t in trade:
with open('names.csv', 'w') as csvfile:
fieldnames = ['fake', 'confidence', 'counter_quantity',