Skip to content

Instantly share code, notes, and snippets.

View FlowerWrong's full-sized avatar
💭
I may be slow to respond.

浮生 FlowerWrong

💭
I may be slow to respond.
View GitHub Profile
@FlowerWrong
FlowerWrong / syn-poc.rb
Created August 14, 2016 18:55 — forked from KINGSABRI/syn-poc.rb
Build TCP/IP packet from scratch by ruby , and send syn(or whatever you want) packet
#!/usr/bin/env ruby
# Full Contol on Ethnet, IP & TCP headers. Play with it ;)
# to test it: nc -lvp 4444
# as root: tcpdump -nvvvv 'tcp port 4444' -i wlan0 # change wlan0 to your interface
# or use packetfu to monitor as tcpdump
## cap = PacketFu::Capture.new(:iface => 'wlan0' , :promisc=> true)
## cap.show_live(:filter => 'tcp and port 4444')
# libpcap should be installed
# gem install pcaprub packetfu
@FlowerWrong
FlowerWrong / one_line_http_server.md
Created December 11, 2017 01:46
One line http server

one line http server

ruby

ruby -run -ehttpd . -p8000

python

@FlowerWrong
FlowerWrong / smart-config.txt
Last active February 27, 2019 02:37
smart config file
# generate from surge.conf
# see https://github.com/FlowerWrong/tun2socks/blob/master/cmd/smart/parser.go
session_name smart
welcome_info Happy New Year!
global_mode false
firewall_mode true
debug true
ip 172.25.0.1
version: '2'
services:
mysql-master:
image: 'bitnami/mysql:8.0'
ports:
- '3306:3306'
volumes:
- 'mysql_master_data:/bitnami/mysql/data'
environment:
group :development, :test do
gem 'awesome_print'
gem 'dotenv-rails'
gem 'seed_dump'
gem 'pry-rails'
gem 'pry-byebug'
gem 'pry-doc'
gem 'rubocop-rails'
{
"ruby.rubocop.executePath": "/Users/xxx/.rbenv/shims/",
"ruby.rubocop.onSave": true,
"ruby.useLanguageServer": false,
"[ruby]": {
"editor.formatOnSave": true
},
"editor.formatOnSave": true,
"editor.formatOnSaveTimeout": 1500,
"solargraph.autoformat": true,
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/kingyang/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="agnoster"
@FlowerWrong
FlowerWrong / file_adapter.rb
Last active August 18, 2020 07:11
write elastic ruby agent apm to file
# frozen_string_literal: true
class FileAdapter
include ElasticAPM::Logging
def initialize(config)
@config = config
@mutex = Mutex.new
@logger_file = File.new('log/apm.log', 'a+')
@FlowerWrong
FlowerWrong / china_region.rb
Created August 20, 2020 09:22
China region
# rails g model ChinaRegion name parent_id lng lat
class AddChinaRegionData < ActiveRecord::Migration[6.0]
def up
# https://github.com/pfinal/city
ChinaRegion.destroy_all
ActiveRecord::Base.connection.reset_pk_sequence!(ChinaRegion.table_name)
data = []
File.open(Rails.root.join('db', 'data', 'region.txt')).each do |line|
next unless /\((.*)\).*/ =~ line
@FlowerWrong
FlowerWrong / application.js
Created September 12, 2020 06:12
rails 6 webpacker gridstack.js
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
import $ from "jquery" // yarn add jquery
// yarn add gridstack
import "gridstack/dist/jq/jquery-ui"
import 'gridstack/dist/gridstack-poly'; // optional IE support