Skip to content

Instantly share code, notes, and snippets.

View aipi's full-sized avatar
❤️
Falling in love

Daniel Moniz aipi

❤️
Falling in love
View GitHub Profile
@aipi
aipi / mysql_server_status.sh
Created February 7, 2017 02:10
MySQL Start, Stop and Restart on MacOS
#To start MySQL:
$ sudo mysql.server start
#To stop MySQL:
$ sudo mysql.server stop
#To restart MySQL:
$ sudo mysql.server restart
@aipi
aipi / mysql_expect_script.sh
Created February 7, 2017 16:03
MySQL expect script to enter into database to avoid to insert sudo password and database password all the time.
#Instead use "mysql -u root -p" and put your sudo password and mysql password use this expect script:
#!/usr/bin/expect -f
#create an alias sql="/Users/macbookpro/Desktop/myProject/mysql-enter.sh"
#To know more about expect: http://www.admin-magazine.com/Articles/Automating-with-Expect-Scripts
spawn mysql -u root -p
expect {
"Password:" {
send "sudo_password\r"
}
@aipi
aipi / massage_time.sh
Created May 12, 2017 14:56
Script to notify massage time
#!/bin/bash
while :
do
Time=`date +%r`
Date=`date +"%d-%m-%Y"`
if [ $Date == '11-05-2017' ] && [ $Time == '15:25:00' ]; then
notify-send -i /home/aipi/Pictures/image.jpg 'MASSAGEM' 'Partiu ficar suave?';
@aipi
aipi / test_django_login_and_subtest_in_template.py
Last active May 17, 2017 03:44
Django subTest() example code and login test example code
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
class (TestCase):
def setUp(self):
self.superuser = User.objects.create_superuser(
email='[email protected]',
password='V&ryD@f3Pwd',
name='Super User')
@aipi
aipi / django_url.py
Last active May 18, 2017 14:18
understanding and joking with Django URLs
from django.conf.urls import urlpatterns
from django.core.urlresolvers import set_urlconf, resolve, reverse
os.eviron.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
def index(request): pass
def auth(request): pass
def list_(request): pass
def edit(request): pass
def new(request): pass
@aipi
aipi / Anaconda.sublime.settings
Created May 17, 2017 16:17
My sublime and configuration to Python and Django
{
"python_interpreter": "python3",
"anaconda_gutter_theme": "alpha",
"anaconda_linter_show_errors_on_save": true,
"pep257": false,
"aggressive": 2,
"pep8_max_line_length": 99,
}
@aipi
aipi / test_url.py
Last active September 15, 2022 09:57
Django - Test that URL resolves to the correct view function
from django.test import TestCase
from django.core.urlresolvers import resolve
from solos.views import index
class SolosURLsTestCase(TestCase):
def test_root_url_uses_index_view(self):
"""Test that
the root of the site resolves to the
@aipi
aipi / test_view_basics.py
Created May 21, 2017 02:55
Django - Test that index view returns a 200 response and uses the correct template
from django.tesst import TestCase
class IndexViewTestCase(TestCase):
def setUp(self):
self.factory = RequestFactory()
def test_index_view_basic(self):
"""Test that index view returns a
200 response and uses the correct
template"""
@aipi
aipi / dynamic_allocation.c
Created June 27, 2017 03:40
Example to dynamic memory alocation in C
#include <stdio.h>
#include <stdlib.h>
int *realoca(int *ptr, int *size) {
int add;
printf("Insira quantos números quer alocar:\n");
scanf("%d", &add);
ptr = (int *) realloc(ptr, (*size + add) * sizeof(int));
@aipi
aipi / example_ajax_view.py
Last active August 30, 2017 16:21
Django Ajax Get Request (Example code)
# It is just a example and not completed code
from django.http import JsonResponse
def ix_detail_pix(request, *args):
""" Ajax PIX info if clicked on PIX """
pix_uuid = request.GET['pix']
data = {}
pix_infos = get_pix_amounts_info(pix_uuid)