Skip to content

Instantly share code, notes, and snippets.

// iPadの場合にcontentのwidthを指定してやらないとdevice-width(768 or 1024)になってしまう
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSString *script = [NSString stringWithFormat:@"document.querySelector('meta[name=viewport]').setAttribute('content', 'width=%d;', false); ", 320];
[webView stringByEvaluatingJavaScriptFromString:script];
}
curl 'https://api.github.com/users/questbeat/gists?page=1' | jq "."
#!/bin/bash
rew tap | sed -e "s/^/tap '/g" | sed -e "s/$/'/g" > Brewfile
brew list | sed -e "s/^/brew '/g" | sed -e "s/$/'/g" >> Brewfile
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <string>
#include <sstream>
using namespace std;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
@nek023
nek023 / supervisord
Created January 11, 2014 11:18
chkconfig script for supervisor (put this script on /etc/rc.d/init.d/supervisord) http://yosida95.hatenablog.com/entry/20120322/1332439575
#!/bin/sh
# chkconfig: - 15 15
# description: Copyright (C) yosida95 All Right Reserved.
. /etc/rc.d/init.d/functions
SUPERVISORD="/usr/bin/supervisord"
PIDFILE="/var/run/supervisord.pid"
@interface UIColor (HSBFunctions)
- (UIColor *)lightenedColorByPercent:(CGFloat)percent;
- (UIColor *)darkenedColorByPercent:(CGFloat)percent;
@end
@nek023
nek023 / LaunchAtLoginController.h
Last active December 12, 2019 04:26
A helper class to manage login items in non-sandboxed app.
//
// LaunchAtLoginController.h
// LaunchAtLoginController
//
// Created by Katsuma Tanaka on 2014/04/12.
// Copyright (c) 2014年 Katsuma Tanaka. All rights reserved.
//
#import <Foundation/Foundation.h>
@nek023
nek023 / knapsack01.c
Last active August 29, 2015 14:00
knapsack problem
#include <stdio.h>
#define NUM 8 // 製品の個数
#define MAX_WEIGHT 25 // ナップサックの容量
// i = 0 1 2 3 4 5 6 7
int w[8] = { 3, 5, 4, 2, 10, 7, 1, 5 }; // 製品の容量
int v[8] = { 3, 7, 6, 3, 13, 9, 2, 6 }; // 製品の利得
// i番目以降の製品で, 容量uの制限があるときの最大利得を返す
@nek023
nek023 / about_qsort.c
Last active August 29, 2015 14:01
About qsort of C lang
#include <stdio.h>
// 2つの要素の大小を比較して, (ソート後の配列で)どちらを先に並べるかを返す関数
int compare(const void * a, const void * b) {
// qsort は配列の中身が何なのか (int なのか, float なのか, それとも独自のデータ型なのか)
// が判らないので, とりあえず (void *) 型で渡してくる.
// こちらはデータの中身が int だと知っているので, ここで int に戻してあげる
int num1 = *(int *)a;
int num2 = *(int *)b;