Skip to content

Instantly share code, notes, and snippets.

View saiday's full-sized avatar
:shipit:
su su su

Saiday saiday

:shipit:
su su su
View GitHub Profile
@saiday
saiday / fanclub.html
Created June 3, 2024 05:47
pseudo code
<!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)
@saiday
saiday / visibility.py
Created January 22, 2024 10:00
bit masing for user visibility
# 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."""
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;
//
// SAWKWebView.swift
//
// Created by Costantino Pistagna on 24/01/2020.
// Copyright © 2020 Sofapps. All rights reserved.
//
import UIKit
import WebKit
import Foundation
let json = """
{
"results":[
{
"blah":"blah",
"nested_object":{
"type":"a",
"id":69,
import Foundation
let json = """
{
"results":[
{
"blah":"blah",
"nested_object":{
"type":"a",
"id":69,
@saiday
saiday / instance_method_curried_function.swift
Last active January 7, 2020 17:22
instance method curried function
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"
func ~=<T>(rhs: KeyPath<T, Bool>, lhs: T) -> Bool {
lhs[keyPath: rhs]
}
func handle(_ character: Character) {
switch character {
case "<":
print("element")
case "#":
print("hashtag")
@saiday
saiday / clear_kotlin_web_view_cache.kt
Created August 20, 2019 10:34
Clear Android web view cache
//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
@saiday
saiday / signals.py
Created August 10, 2019 16:17
edited create profile signals (from: https://www.youtube.com/watch?v=FdVuKt_iuSI)
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: