Skip to content

Instantly share code, notes, and snippets.

View Xenofex's full-sized avatar

Eli Wang Xenofex

View GitHub Profile
2013-10-10 15:18:17:963 ityzDev[21063:907] [HTTP] PUT /Run/run_52552bbd55ddd, params: {
price = "23.11";
}, app state: {
"active_hail" = "hail_52552bb3cbf63";
"active_run" = "run_52552bbd55ddd";
"app_state" = 0;
"has_wifi" = 1;
"location_accurary" = "-2";
"location_distance" = 10;
synchronization = "sync_5256545980416";
@Xenofex
Xenofex / base_uploader.rb
Created October 10, 2014 07:52
CarrierWave with backup url from the fog, quick and dirty. Useful for pulling production data to development, in case you have to pull all the UGC as well
# Copy the file from S3 to local public folder
def copy_to_local!(recursive=true)
public_folder = Rails.root.join("public")
path = self.path
if path.start_with?(public_folder.to_s)
local_path = path
path = path[(public_folder.to_s.length+1)..path.length]
else
local_path = public_folder.join(path)
@Xenofex
Xenofex / genstrings.sh
Created November 3, 2014 06:55
genstrings for Swift
#!/bin/bash
#
# genstrings which searchs both Objective-C .m files and Swift files
#
# Set the 'PROJECT' variable
# I'm using a short function 'LS' to replace NSLocalizedString. This script searches them both.
#
if ! type -P ggrep >/dev/null; then
>&2 echo "Error: GNU grep 'ggrep' not found. Install by 'brew install homebrew/dupes/grep'"
package com.lettrs.lettrs.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import com.lettrs.lettrs.R;
import lombok.Getter;
import lombok.Setter;
@Xenofex
Xenofex / ScanController.scala
Created April 11, 2015 08:54
ScanController用scala写了一遍
package com.jikabao.scala.merchant
import java.util
import java.util.{Collections, Date}
import com.google.common.collect.{Lists, Iterables}
import com.jikabao.common.ServiceResult
import com.jikabao.common.domain._
import com.jikabao.common.enums.QrCodeActionEnum._
import com.jikabao.common.service.UserHolder
.modal {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 100;
.bg {
position: absolute;
@Xenofex
Xenofex / coffee_script_source_maps_in_dev.rb
Last active January 18, 2016 11:12
An initializer to enable source maps for coffee script in Rails 4.2.5/Sprockets 3.5.2
if Rails.env.development?
require "base64"
module Sprockets
module CoffeeScriptProcessor
DEFAULT_OPTIONS = { "sourceMap" => true }
def self.call(input)
data = input[:data]
input[:cache].fetch([self.cache_key, data]) do
@Xenofex
Xenofex / parse_log.rb
Created December 27, 2017 18:02
解析日志,提取集点请求参数的一个例子
# vim: set nu sw=2 sts=2:
require 'zlib'
class LogParser
class Request
attr_accessor :path, :method, :ip, :started_at, :end_at, :status, :duration, :parameters, :api_key, :id
def parameters=(parameters)
@parameters = parameters
@Xenofex
Xenofex / redis-keys-size.sh
Created May 20, 2018 00:43
Search redis keys for a pattern, get total memory usage of all the keys and values of them
redis-keys-size() {
redis-cli keys "$1" | awk '{ system("redis-cli memory usage \x27" $0 "\x27") }' | cut -d ' ' -f 2 | awk '{s+=$1} END {print s}'
}
@Xenofex
Xenofex / 门店上架.js
Last active June 6, 2018 05:06
支付宝口碑后台操作
window.$ = jQuery;
nextPage = () => new Promise((resolve => {
$('[data-role=next]').click();
$(document).one("ajaxComplete", () => {
resolve()
})
}));