This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>URL Manipulation Example</title> | |
<script> | |
document.addEventListener('DOMContentLoaded', () => { | |
// Assuming URL A is 'http://example.com/pageA' and URL B is 'http://example.com/pageB' | |
// Step 1: Load content from URL B (this can be done via AJAX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Constants representing each status as bit flags | |
ENABLE = 1 << 0 # 0b000001 | |
BLOCKED_BY_GLOBAL = 1 << 1 # 0b000010 | |
BLOCKED_BY_CN = 1 << 2 # 0b000100 | |
COPYRIGHT_GLOBAL = 1 << 3 # 0b001000 | |
COPYRIGHT_CN = 1 << 4 # 0b010000 | |
PENDING_DELETION = 1 << 5 # 0b100000 | |
def set_status(status_flags, condition): | |
"""Set a specific condition.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.streetvoice.streetvoice.player; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.nio.ByteBuffer; | |
import java.nio.ByteOrder; | |
import java.nio.ShortBuffer; | |
import java.util.Arrays; | |
import java.util.LinkedList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SAWKWebView.swift | |
// | |
// Created by Costantino Pistagna on 24/01/2020. | |
// Copyright © 2020 Sofapps. All rights reserved. | |
// | |
import UIKit | |
import WebKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let json = """ | |
{ | |
"results":[ | |
{ | |
"blah":"blah", | |
"nested_object":{ | |
"type":"a", | |
"id":69, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let json = """ | |
{ | |
"results":[ | |
{ | |
"blah":"blah", | |
"nested_object":{ | |
"type":"a", | |
"id":69, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class C { | |
func printla(_ msg: String) { print(msg) } | |
func getPrinter(_ msg: String) -> (String)->() { return { msg in self.printla(msg) } } | |
} | |
let c = C() | |
let im = C.printla // im is of type (C)->(String)->(), | |
im(c)("who let the dogs out") // prints "who let the dogs out" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ~=<T>(rhs: KeyPath<T, Bool>, lhs: T) -> Bool { | |
lhs[keyPath: rhs] | |
} | |
func handle(_ character: Character) { | |
switch character { | |
case "<": | |
print("element") | |
case "#": | |
print("hashtag") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//helper method for clearCache() , recursive | |
//returns number of deleted files | |
fun clearCacheFolder(dir: File?, numDays: Int): Int { | |
var deletedFiles = 0 | |
if (dir != null && dir!!.isDirectory()) { | |
try { | |
for (child in dir!!.listFiles()) { | |
//first delete subdirectories recursively |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.db.models.signals import post_save | |
from django.dispatch import receiver | |
from users.models import Profile | |
@receiver(post_save, sender=User) | |
def create_profile(sender, instance, created, **kwargs): | |
if created: |
NewerOlder