Skip to content

Instantly share code, notes, and snippets.

🖥
C64/Amiga Scener/Coder

Uğur Özyılmazel vigo

🖥
C64/Amiga Scener/Coder
Block or report user

Report or block vigo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sarthology
sarthology / regexCheatsheet.js
Created Jan 10, 2019
A regex cheatsheet 👩🏻‍💻 (by Catherine)
View regexCheatsheet.js
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@hakib
hakib / admin.py
Last active Oct 3, 2019
How to Turn Django Admin Into a Lightweight Dashboard
View admin.py
# https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard
from django.contrib import admin
from django.db.models import Count, Sum, Min, Max, DateTimeField
from django.db.models.functions import Trunc
from . import models
def get_next_in_date_hierarchy(request, date_hierarchy):
View main.go
package main
import (
"fmt"
"log"
"os"
"sync"
"time"
)
@LowerDeez
LowerDeez / admin.py
Created Oct 6, 2017
Django. Admin Tabular Inline initial data
View admin.py
from django.utils.functional import curry
class DetailsInline(admin.TabularInline):
model = Details
formset = DetailsFormset
extra = 3
def get_formset(self, request, obj=None, **kwargs):
initial = []
if request.method == "GET":
@ipmb
ipmb / settings.py
Last active Oct 7, 2019
Django logging example
View settings.py
import logging.config
import os
from django.utils.log import DEFAULT_LOGGING
# Disable Django's logging setup
LOGGING_CONFIG = None
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
logging.config.dictConfig({
@mariocj89
mariocj89 / python-logging.md
Last active Oct 14, 2019
Understanding logging in Python
View python-logging.md

Logging trees

Introduction

When applications are running in production, they become black boxes that need to be traced and monitored. One of the simplest, yet main, ways to do so is logging. Logging allows us - at the time we develop our software - to instruct the program to emit information while the system is running that will be useful for us and our sysadmins.

@reagent
reagent / 01_basic.go
Last active Oct 15, 2019
Custom HTTP Routing in Go
View 01_basic.go
package main
import (
"io"
"log"
"net/http"
)
func main() {
View A slack_logger.py
import requests
import json
import time
import math
from copy import copy
from django.conf import settings
from django.utils.log import AdminEmailHandler
from django.views.debug import ExceptionReporter
class SlackExceptionHandler(AdminEmailHandler):
@simonw
simonw / recover_source_code.md
Last active Oct 17, 2019
How to recover lost Python source code if it's still resident in-memory
View recover_source_code.md

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@varver
varver / .Title
Created Nov 29, 2016 — forked from congjf/.Title
Using MongoDB in golang with mgo
View .Title
Using MongoDB in golang with mgo
You can’t perform that action at this time.