Skip to content

Instantly share code, notes, and snippets.

View ilhamije's full-sized avatar
🏠
Working from home, as always.

Ilham Akbar ilhamije

🏠
Working from home, as always.
View GitHub Profile
@alexaleluia12
alexaleluia12 / flask_logging_requests.py
Last active March 19, 2024 13:49
Flask Logging (every request)
#/usr/bin/python
# http://exploreflask.com/en/latest/views.html
# https://stackoverflow.com/questions/51691730/flask-middleware-for-specific-route
# https://dev.to/rhymes/logging-flask-requests-with-colors-and-structure--7g1
import logging
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
@alpiepho
alpiepho / using_meld_on_mac.md
Last active December 28, 2023 00:56
Using meld on Mac

More Using Meld merging tool on Mac

After switching to 'Meld for Mac' from download instead of from homebrew, I saw problem again.

The problem is related how the app is closed. If you use the Menu option, the saved state is removed cleaning. If you close using the window close (read circle), the saved state remains. Somehow, when this there, the application will not open from command line. Sometimes it will open, but you need to manually switch to the Meld application from the tool bar.

To work around I added /Applications/Meld.app/Contents/MacOS/meld.wrapper.sh:

//Example Usage of custom control
export default ({lat, lng, google}) => (
<GoogleMap
defaultCenter={{lat, lng}}
defaultZoom={14}
minZoom={6}
google={google}
containerStyle={{ height: '575px', width: '100%', position: 'relative' }}
>
<Marker position={{lat, lng}} />
@rikenmehta03
rikenmehta03 / docker_setup.sh
Last active November 21, 2021 02:51
Script to install & setup docker and related tools.
#!/usr/bin/env bash
: '
Script works on Ubuntu 16.04 & Ubuntu 14.04
Installation script for docker
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
'
sudo apt-get remove -y docker docker-engine docker.io
from flask import Flask
from flask_restful import Api, Resource, reqparse
app = Flask(__name__)
api = Api(app)
users = [
{
"name": "Nicholas",
"age": 42,
@sirodoht
sirodoht / migrate-django.md
Last active April 20, 2024 09:52
How to migrate Django from SQLite to PostgreSQL

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 manage.py dumpdata > datadump.json

Change settings.py to Postgres backend.

Make sure you can connect on PostgreSQL. Then:

@romgapuz
romgapuz / pg_create_user_db_with_grant.sql
Created April 4, 2017 13:47
PostgreSQL Create User and Database and grant permission
CREATE USER username WITH PASSWORD 'password';
CREATE DATABASE database_name;
GRANT ALL PRIVILEGES ON DATABASE database_name to username;
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active May 7, 2024 22:00
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

export const GoogleApi = function(opts) {
opts = opts || {}
const apiKey = opts.apiKey;
const libraries = opts.libraries || [];
const client = opts.client;
const URL = 'https://maps.googleapis.com/maps/api/js';
const googleVersion = '3.22';
let script = null;
@udacityandroid
udacityandroid / MainActivity.java
Created June 27, 2015 23:17
Android for Beginners : Menu Solution Code
package com.example.android.menu;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {