Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / .slate.js
Last active November 18, 2021 16:13
slate configuration
var pushRight = slate.operation("push", {
"direction": "right",
"style": "bar-resize:screenSizeX/2"
});
var pushLeft = slate.operation("push", {
"direction": "left",
"style": "bar-resize:screenSizeX/2"
});
@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()
@gfreezy
gfreezy / if_not_running
Created June 17, 2013 08:41
run only one process a time. if_not_runnig && cmd
#!/usr/bin/env bash
# exit when no parameter provided
test -z "$*" && exit 0
id=`echo "$*" | md5sum | cut -d " " -f 1`
idfile="/tmp/$id"
if [ ! -e $idfile ]; then
touch $idfile
$@
rm $idfile
exit -1