Skip to content

Instantly share code, notes, and snippets.

@gfreezy
gfreezy / sync-xcode-preview.py
Last active September 23, 2022 14:56
Copy privileges from simulator to xcode preview & copy photos from simulator to preview
"""
Use the following code in xcode preview to get the simulator path. Xcode preview does not support print or log to console.
So you need to use a `Text` view to show the path.
`
NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, .userDomainMask, true)
`
"""
import pathlib
import subprocess
@gfreezy
gfreezy / migrate.sh
Last active January 23, 2024 17:06
Hacking native ARM64 binaries to run on the iOS Simulator
#!/usr/bin/env bash
set -ex
# https://bogo.wtf/arm64-to-sim.html
ios_plat=ios
simulator_plat=simulator
make() {
for name in $@; do
@gfreezy
gfreezy / .travis.yml
Created August 25, 2019 07:34
cache brew cache in travis
cache:
directories:
- $TRAVIS_BUILD_DIR/target
# https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew/
# used in OSX custom build script dealing with local bottle caching
- $HOME/local_bottle_metadata
addons:
homebrew:
extern crate bitcask_rs;
extern crate actix_web;
extern crate actix;
extern crate failure;
extern crate futures;
use failure::{Fail, Error};
use futures::future::{Future, result};
use actix_web::{server, App, HttpRequest, Responder, FutureResponse, HttpResponse, AsyncResponder};
use std::path::PathBuf;
// Copyright 2015, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
class ImageDto(Model):
ident = StringType()
height = IntType()
width = IntType()
max_height = IntType()
max_width = IntType()
url_pattern = StringType()
impl ConnectionPool {
pub fn get_client<'a>(&'a self, addr: &str) -> Option<&'a rpc::Client> {
if let Some(&Ok(ref c)) = self.conns.get(addr) {
return Some(c);
}
let c = rpc::Client::new(addr);
self.conns.insert(addr.to_string(), c);
if let Some(&Ok(ref c)) = self.conns.get(addr) {
@gfreezy
gfreezy / test.py
Last active October 20, 2016 14:12
import subprocess
path = '/mfs/test/%d.xlsx'
def write(file_path):
from xlsxwriter import Workbook
wb = Workbook(file_path)
st = wb.add_worksheet('test')
for i in range(10):
st.write(i, i, 'aa')
wb.close()
#include "tlpi_hdr.h"
int
main(int argc, char *argv[])
{
printf("Hello world\n");
write(STDOUT_FILENO, "Ciao\n", 5);
if (fork() == -1)
errExit("fork");
/* Both child and parent continue execution here */
@gfreezy
gfreezy / encrypt.py
Created September 19, 2014 07:22
自动使用爱加密加密apk
#!/usr/bin/env python
import os
import requests
import time
import sys
from collections import namedtuple
LOGIN_PATH = 'http://www.ijiami.cn/toLogin'
UPLOAD_PATH = 'http://www.ijiami.cn/upload/'