Skip to content

Instantly share code, notes, and snippets.

View banister's full-sized avatar
🇳🇱

John Mair banister

🇳🇱
View GitHub Profile
/* Copied, Pasted and summarized from ps' source code.
You can use sysctl to get other process' argv.
*/
#include <sys/sysctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define pid_of(pproc) pproc->kp_proc.p_pid
@banister
banister / bpf.c
Created April 2, 2021 03:58 — forked from c-bata/bpf.c
Capture packets from bpf devices on macOS.
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>
#include <string.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <net/bpf.h>
class UserCreator
def initialize(listener)
@listener = listener
end
def create(attributes)
user = User.new(attributes)
if user.save
# send email
print "Enter a count: "
count = gets.chomp.to_i
values = []
count.times do
print "Enter a value: "
values << gets.chomp.to_i
end
module Domain¬
class CollaboratorRepository¬
def self.add(project, users)¬
users.each do |user|¬
user = User.find(user) if user.is_a?(BSON::ObjectId)¬
project.collaborator_ids << user.id unless !user.is_a?(User) or user.guest? or project.collaborator_ids.include?(user.id)¬
S
puts "Nhap vao ba so nguyen a, b, c (a # 0)."
a = 0
until a != 0
puts "a: "
a = gets.chomp.to_f
end
puts "b: "
b = gets.chomp.to_f
puts "c: "
c = gets.chomp.to_f
class Child
end
age = 12
test_module = Module.new do
define_method(:say_hello) do
puts "Hello from module, I am #{age} years old"
end
end
def replace_line_in_file(old,new,file)
@fst = File.read(file)
@fst.gsub!(old,new)
File.open(file,"w") {|f| f.puts @fst}
end
class BaseClass; end
class ChildClass < BaseClass
acts_as_content
end
class OtherChildClass < BaseClass; end
module ActsAsContent
commands = Pry::CommandSet.new do
import_from Pry::Commands, "help"
command "start" do
puts "Start"
end
command "stop" do
puts "Stop"
end
command "start_handler" do