Skip to content

Instantly share code, notes, and snippets.

@syxc
syxc / buildAndTest.yaml
Created May 14, 2024 05:09 — forked from felix-larsen/buildAndTest.yaml
iOS App with CocoaPods Test Automation with GitHub Actions CI
name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
buildAndTest:
runs-on: macos-latest
steps:
@syxc
syxc / closeAppElegantly.swift
Created July 12, 2022 01:31 — forked from yoni-g/closeAppElegantly.swift
How to exit an iOS app without it looking like a crash? - Swift
func showMessageResetApp(){
let exitAppAlert = UIAlertController(title: "Restart is needed",
message: "We need to restart the app on your first login to the app.\n Please reopen the app after this.",
preferredStyle: .alert)
let resetApp = UIAlertAction(title: "Close Now", style: .destructive) {
(alert) -> Void in
// home button pressed programmatically - to thorw app to background
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
// terminaing app in background

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
package com.yourpackagename;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
@syxc
syxc / github.css
Last active August 29, 2015 14:05 — forked from theconektd/github.css
body {
font-family: Helvetica, arial, sans-serif;
font-size: 16px;
line-height: 1.6;
padding: 10px;
background-color: white;
}
body > *:first-child {
margin-top: 0 !important;
@syxc
syxc / CommonMacro.h
Last active April 14, 2017 09:09 — forked from ondev/gist:6714742
常用的 iOS 开发宏
//
// CommonMacro.h
//
//
// Created by Haven on 26/9/13.
// Copyright (c) 2013 LF. All rights reserved.
//
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
@syxc
syxc / app.js
Created October 14, 2013 11:47 — forked from clarle/app.js
// Module dependencies
var express = require('express'),
mysql = require('mysql');
// Application initialization
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
"""
tornado_static is a module for displaying static resources in a Tornado web
application.
It can take care of merging, compressing and giving URLs ideal renamings
suitable for aggressive HTTP caching.
(c) mail@peterbe.com
"""
"""
http://saepy.sinaapp.com/topic/24/Tornado%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%E7%A4%BA%E4%BE%8B
在bcore的开发过程中,涉及到上传文件有两个地方,一个是相册,一个是文章图文混排。这里作为一个备忘。罗列一些关键点:
文件上传的内容体在tornado.web.RequestHandler.request.files属性中,并且是以数组形式存放的。
使用临时文件存储时,在write完成后要记着把seek重置到文件头。要不然文件无法被读取。
再使用Image模块的thumbnail方法进行缩放时,resample=1作为重载渲染参数能够有效的使图片平滑,消除锯齿。
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
height, @"user[height]",
weight, @"user[weight]",
nil];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:
[NSURL URLWithString:@"http://localhost:8080/"]];
[client postPath:@"/mypage.php" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *text = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];