This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserCreator | |
| def initialize(listener) | |
| @listener = listener | |
| end | |
| def create(attributes) | |
| user = User.new(attributes) | |
| if user.save | |
| # send email |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print "Enter a count: " | |
| count = gets.chomp.to_i | |
| values = [] | |
| count.times do | |
| print "Enter a value: " | |
| values << gets.chomp.to_i | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BaseClass; end | |
| class ChildClass < BaseClass | |
| acts_as_content | |
| end | |
| class OtherChildClass < BaseClass; end | |
| module ActsAsContent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
NewerOlder