Skip to content

Instantly share code, notes, and snippets.

@losingle
losingle / PKPass.md
Created June 17, 2023 12:32 — forked from rlanyi/PKPass.md
How to create Apple PKPass .p12 certificate using Linux

How to create Apple PKPass .p12 certificate using Linux

You don't need a Mac to do this :-)

For generating PKPass files, you'll need 4 things after this tutorial:

  • Certificate Identifier (pass.com.example.www)
  • Team Identified (Organizational Unit (OU) in the cert generated by Apple)
  • The .p12 file
  • The password for the .p12 file
@losingle
losingle / README.md
Created June 5, 2023 02:35 — forked from equivalent/README.md
Rails 7 importmaps dropzone.js direct upload ActiveStorage

This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.

@losingle
losingle / nginx-tuning.md
Created May 31, 2019 02:39 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@losingle
losingle / libz.sh
Created December 2, 2016 23:15 — forked from dulacp/libz.sh
Download & Compile Libz (zlib) for iOS (all architectures)
# Builds a ZLib framework for the iPhone and the iPhone Simulator.
# Creates a set of universal libraries that can be used on an iPhone and in the
# iPhone simulator. Then creates a pseudo-framework to make using libz in Xcode
# less painful.
#
# To configure the script, define:
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 8.1)
#
# Then go get the source tar.bz of the libz you want to build, shove it in the
# same directory as this script, and run "./libz.sh". Grab a cuppa. And voila.
@losingle
losingle / README.md
Created September 22, 2015 15:36 — forked from nicerobot/README.md
Mac OS X uninstall script for packaged install of node.js

To run this, you can try:

curl -ks https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh | bash

I haven't tested this script doing it this way but i run a lot of my Gists like this so maybe this one'll work too.

Alternatively,

curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh

chmod +x ./uninstall-node.sh

module ApiPagination
Infinity = 1.0/0
class Range < Grape::Validations::SingleOptionValidator
def validate_param!(attr_name, params)
unless (!@required && params[attr_name].nil?) || @option.include?(params[attr_name])
throw :error, status: 400, message: "#{attr_name}: must be within #{@option}"
end
end
end
# you have ctags but it does not work...
$ ctags -R --exclude=.git --exclude=log *
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
#you need to get new ctags, i recommend homebrew but anything will work
$ brew install ctags
#alias ctags if you used homebrew
$ alias ctags="`brew --prefix`/bin/ctags"
#!/usr/bin/env ruby
# Please read http://otobrglez.opalab.com for more information about this code.
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end
@losingle
losingle / send_csv.rb
Created December 25, 2013 03:43 — forked from mimosz/send_csv.rb
# -*- encoding: utf-8 -*-
require 'csv'
require 'smsbao'
class SendCsv < Smsbao
def initialize(login, passwd)
@smser = Smsbao.new(login, passwd)
end
def import(csv_file, col_sep=',') # MAC下为;

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb