Skip to content

Instantly share code, notes, and snippets.

View CaliosD's full-sized avatar
🎯
Focusing

Calios CaliosD

🎯
Focusing
  • Ubuntu
View GitHub Profile
@cb109
cb109 / remove_custom_fk_uniqueconstraint_django_mysql.md
Last active February 9, 2024 18:42
Fix: Cannot remove UniqueConstraint on ForeignKey with Django/MySQL

Django allows you to define custom UniqueConstraints to specify which combinations of values are allowed in a row, but removing these later can be problematic when some ForeignKey is involved, at least with MySQL it may throw a Cannot drop index '...': needed in a foreign key constraint at you.

The example below shows you how to resolve such a situation in 3 small individual migrations:

  • We start with an existing UniqueConstraint.
class MyModel(models.Model):
    other_model = models.ForeignKey("OtherModel", on_delete=models.CASCADE)
    name = models.CharField(max_length=128)
/**
use:
```js
import router from "<you router path>"
import KeepScroll from "<you code path>"
Vue.use(KeepScroll, { router })
```
@sullof
sullof / Eventron
Last active January 10, 2019 20:14
A gist to run Eventron — an alternative to Tron Quickstart
### Usage
1. Create `docker-compose.yaml` and `up.sh` on your computer
2. Make `up.sh` executable (`chmod +x up.sh`)
3. Run `./up.sh`
You can force pre-approval of proposals commenting/uncommenting variables in the section
```
environment:
- allowTvmTransferTrc10=1
@josephchang10
josephchang10 / blockchain.swift
Created December 27, 2017 14:25
在 iOS 中实现区块链
import Cocoa
import Foundation
class Block {
var index: Int = 0
var dateCreated: String
var previousHash: String!
var hash: String!
var nonce: Int
@JoshuaSullivan
JoshuaSullivan / CapturedImageSampler.swift
Created October 1, 2017 01:38
The source code for an object that helps you sample RGB values from ARFrames.
//
// CapturedImageSampler.swift
// ARKitTest
//
// Created by Joshua Sullivan on 9/22/17.
// Copyright © 2017 Joshua Sullivan. All rights reserved.
//
import UIKit
import ARKit
@tad-iizuka
tad-iizuka / ViewController.swift
Last active November 7, 2022 16:43
Photo Capture Sample Swift 4 + iOS 11
//
// ViewController.swift
// PhotoCaptureSample
//
// Created by Tadashi on 2017/09/23.
// Copyright © 2017 UBUNIFU Incorporated. All rights reserved.
//
import UIKit
import AVFoundation
import Photos
@petergloor
petergloor / main.go
Created January 25, 2017 13:00
MaxInt, MinInt, MaxUint and MinUint in Go (golang)
package main
import "fmt"
// Constant definitions
const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(^uint(0) >> 1)
const MinInt = -MaxInt - 1
@simme
simme / debounce-throttle.swift
Created December 20, 2016 10:04
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {
@Ashton-W
Ashton-W / RemoveATSExceptions.sh
Last active October 15, 2022 03:46
Xcode Build Phase Script to remove NSAppTransportSecurity from the Info.plist based on the custom REMOVE_ATS_EXCEPTIONS build setting.
#!/usr/bin/env bash
# Build Phase Script for removing NSAppTransportSecurity exceptions from Info.plist
# https://gist.github.com/Ashton-W/07654259322e43a2b6a50bb289e72627
set -o errexit
set -o nounset
if [[ -z "${REMOVE_ATS_EXCEPTIONS+SET}" ]]; then
echo "error: User Defined Build Setting REMOVE_ATS_EXCEPTIONS must be set"
exit 1
@KiranPanesar
KiranPanesar / NTVImageView.h
Created October 27, 2015 15:57
A UIImageView subclass which allows for external memers to set the intrinsicContentSize
//
// NTVImageView.h
//
// Created by kiran on 27/10/2015.
//
#import <UIKit/UIKit.h>
@interface NTVImageView : UIImageView