Skip to content

Instantly share code, notes, and snippets.

@jamesmfriedman
jamesmfriedman / rename_table_migration.py
Last active February 8, 2022 18:56
Renaming a Django app that has migrations already sucks. This Is a way I found to do it that preserves your old migration history and keeps your contenttypes in order. The trick is, this migration cannot be in the app you are migrating, so stick it in your "core" app or another app you have installed. Just plug in your own old and new app names.
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
from django.db.models import get_app, get_models
class Migration(SchemaMigration):
@pixeline
pixeline / index.html
Last active May 26, 2019 03:44
Simple way to implement a stylesheet switcher, using jquery and proper html. Add your stylesheets to your <head> tag: <link rel="alternate stylesheet" title="red" href="css/red.css" type="text/css"> Include the jquery stylesheet switcher. Done.
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<link rel="stylesheet" title="main" href="normalize.min.css" type="text/css">
<link rel="stylesheet" title="main" href="main.css" type="text/css">
<link rel="alternate stylesheet" title="red" href="red.css" type="text/css">
<link rel="alternate stylesheet" title="blue" href="blue.css" type="text/css">
@dysfunc
dysfunc / angular-deep-extend.js
Last active March 2, 2017 01:30
angular.extend - shallow + deep copy (supports merging of arrays and deduping)
/**
* Deep copy example:
* angular.extend(true, { hello: 'world', app: { id: '1234', groups: [{ id: 1},2,3,4,5] }, ids: [1,2,3] }, { app: { name: 'bond', groups: [6, 7, {hello:'world', test: [1,2,3,4, [12,34,45]]}, 9] }, ids: [4,5,6,3] });
* => "{"hello":"world","app":{"id":"1234","groups":[{"id":1},2,3,4,5,6,7,{"hello":"world","test":[1,2,3,4,[12,34,45]]},9],"name":"bond"},"ids":[1,2,3,4,5,6,3]}"
*
* Deep copy and dedup arrays
* angular.extend(true, true, { hello: 'world', app: { id: '1234', groups: [{ id: 1},2,3,4,5] }, ids: [1,2,3] }, { app: { name: 'bond', groups: [6, 7, {hello:'world', test: [1,2,3,4, [12,34,45]]}, 9] }, ids: [4,5,6,3] });
* => "{"hello":"world","app":{"id":"1234","groups":[{"id":1},2,3,4,5,6,7,{"hello":"world","test":[1,2,3,4,[12,34,45]]},9],"name":"bond"},"ids":[1,2,3,4,5,6]}"
*
* vs jQuery deep copy
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing
@marty-wang
marty-wang / gist:5a71e9d0a6a2c6d6263c
Last active June 27, 2024 13:34
Compile and deploy React Native Android app of Release version to device.
Disclaimer: The instructions are the collective efforts from a few places online.
Nothing here is my original. But I want to put them together in one place to save people from spending the same time as I did.
First off, bundle.
==================
1. cd to the project directory
2. Start the react-native packager if not started
3. Download the bundle to the asset folder:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
@wilhelmklopp
wilhelmklopp / django-basic-slack-OAuth.py
Last active December 23, 2019 09:31
Example of how do to a basic Slack OAuth implementation in Django
# urls.py
from django.conf.urls import url
from main import views
urlpatterns = [
url(r'^oauthcallback/', views.oauthcallback)
]
# models.py
from django.db import models
@jvorcak
jvorcak / tig.md
Last active October 11, 2019 17:24
tig - Text-mode interface for git

tig - Text-mode interface for git

This is a proposal for #ReactiveConf 2017 open call for Lightning talks.


Do you think that using git command line tool is the most efficient way of interacting with your repository? In this lightning talk, I will introduce tig - the ncurses front-end for git, which will make your interaction with git much more efficient.

tig combines the advantages of the command line and GUI tools like qgit. With a couple of keystrokes, you are

@jukben
jukben / android_Fastlane
Last active October 28, 2021 10:51
Example of Circle CI config for React Native CI (Appcenter, Kotlin, Swift, RN 0.49+, Haul packager, signing via Match, be sure that you have set env MATCH_PASSWORD, FASTLANE_PASSWORD and SLACK_URL)
fastlane_version "2.64.1"
default_platform :android
platform :android do
lane :beta do
gradle(task: "assembleRelease")
appcenter_upload(
api_token: "",
@jukben
jukben / Fastlane
Created March 29, 2018 12:30
Fastlane – example how to increment versions based on package.json
# ios
match(...)
package = load_json(json_path: "../package.json")
increment_version_number(version_number: package["version"])
increment_build_number(build_number: ENV["CIRCLE_BUILD_NUM"] || 1)
# android
package = load_json(json_path: "../package.json")