Skip to content

Instantly share code, notes, and snippets.

View roma-guru's full-sized avatar
🌴
In Cyprus

Roman Voropaev roma-guru

🌴
In Cyprus
View GitHub Profile
@leifdenby
leifdenby / migration_loaddata.py
Last active December 9, 2020 19:28
Django function for loading fixtures which use the current migration state of the model
from django.core import serializers
import os
def loaddata(fixture_name, apps, ignorenonexistent=True):
"""
Loads migrations that work at current state of a model, in constrast to
`loaddata` which requires a fixture to have data matching the fields
defined in `models.py`.
@danni
danni / migration_loaddata.py
Last active November 16, 2023 08:28 — forked from leifdenby/migration_loaddata.py
Django function for loading fixtures which use the current migration state of the model
import os
import logging
from django.core import serializers
LOGGER = logging.getLogger(__name__)
def load_fixture(app, fixture, ignorenonexistent=True):
"""
@haosdent
haosdent / x_layout.keylayout
Last active February 11, 2025 09:07
Mac OS X Keyboard layout file, works in 10.11
<?xml version="1.1" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--
Data generated Wed Mar 23 01:35:41 2022
Generated by kluchrtoxml_64 build 203
-->
<!--Last edited by Ukelele version 351 on 2022-03-23 at 01:45 (GMT+8)-->
@hlissner
hlissner / codesign_gdb.md
Last active September 29, 2024 00:25
Codesign gdb on OSX
@lvm
lvm / README.md
Created February 13, 2017 16:37
[WIP] hackish emacs mode for FoxDot

Installation

  1. put foxdot-cli.py in the same directory as the FoxDot installaton (in case you're using virtualenv, otherwise comment from lines 5 to 7)
  2. copy foxdot-mode.el to ~/.emacs.d/lisp
  3. add (defvar foxdot-cli-path "/path/to/foxdot-cli/") in your ~/.emacs file
  4. in Emacs M-x load-library and complete with foxdot-mode
  5. Type C-c C-f or M-x foxdot-start to start
  6. Type C-c C-e or M-x foxdot-execute to evaluate a line or a block of code
@flaviocopes
flaviocopes / check-substring-starts-with.go
Last active June 23, 2024 09:05
Go: check if a string starts with a substring #golang
package main
import (
"strings"
)
func main() {
strings.HasPrefix("foobar", "foo") // true
}
import hashlib
from functools import wraps
from django.core.cache import cache
from django.utils.encoding import force_text, force_bytes
def cache_memoize(
timeout,
prefix='',
@Artiomio
Artiomio / keyboard_fly.py
Last active October 11, 2021 11:21
Python Linux/Windows async keyboard library - non-blocking keyboard input - read one character at a time
from __future__ import print_function
try:
import msvcrt
def key_pressed():
return msvcrt.kbhit()
def read_key():
key = msvcrt.getch()
@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active April 28, 2025 06:11
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).