Skip to content

Instantly share code, notes, and snippets.

View glebtv's full-sized avatar

Gleb glebtv

View GitHub Profile
@glebtv
glebtv / LogAfterRequest.php
Created November 25, 2021 11:47 — forked from Shelob9/LogAfterRequest.php
Log all request to Laravel app. Based on http://blog.phakeapps.com/2015/06/23/log-every-request-and-response-in-laravel-5/ updated for Laravel 5.3
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Log;
class LogAfterRequest {
public function handle($request, \Closure $next)
{
return $next($request);
}
<template lang="pug">
.pagination
a.pagination__first(:class="{disabled: page == 1}" @click="setPage(1)")
a.pagination__prev(:class="{disabled: page == 1}" @click="setPage(page - 1)")
a.pagination__page(v-for="p in visiblePages", :class="{active: page == p, disabled: p == '...'}" @click="setPage(p)") {{p}}
a.pagination__next(:class="{disabled: page == totalPages}" @click="setPage(page + 1)")
a.pagination__last(:class="{disabled: page == totalPages}" @click="setPage(totalPages)")
</template>
<script>
[ 34.173417] usb 1-2: new high-speed USB device number 6 using xhci_hcd
[ 53.745299] mt7610u: loading out-of-tree module taints kernel.
[ 53.747531]
=== pAd = ffffc90001506000, size = 895272 ===
[ 53.747592] <-- RTMPAllocTxRxRingMemory, Status=0
[ 53.747620] <-- RTMPAllocAdapterBlock, Status=0
[ 53.747702] ==>MT76x0_WLAN_ChipOnOff(): OnOff:1, Reset= 0, pAd->WlanFunCtrl:0x0, Reg-WlanFunCtrl=0xff000002
[ 53.748159] pChipOps->eeread = RTUSBReadEEPROM16
> ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.31 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.776 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.638 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.674 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.595 ms
64 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=146 ms
64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=2.25 ms
64 bytes from 192.168.1.1: icmp_seq=26 ttl=64 time=156 ms
RocketCMS.patch 'Page' do
model do
has_attached_file :icon
validates_attachment_content_type :icon, content_type: /\Aimage\/.*\Z/
end
edit do
field :icon
end
end
class NavRenderer < SimpleNavigation::Renderer::List
def icon_for(item)
(if item.send(:options)[:icon]
"<img class='icon' src='#{item.send(:options)[:icon]}' alt=''/> ".html_safe
else
""
end) + item.name
end
def tag_for(item)
if suppress_link?(item)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
def thread_state(thr)
vars = Hash[thr.thread_variables.map do |k|
[k, thr.thread_variable_get(k)]
end]
{
status: thr.status,
stop: thr.stop?,
alive: thr.alive?,
aoe: thr.abort_on_exception,
backtrace: thr.backtrace,
@glebtv
glebtv / work.rb
Created December 4, 2013 15:47 — forked from rklemme/work.rb
require 'set'
LOCK = Mutex.new
num = Integer(ARGV.shift || 4)
processes = Set.new
Signal.trap "INT" do |s|
$stderr.puts "Shutdown"
require 'msgpack'
require 'thread'
class ProcessPool
def initialize(num_process, args={})
queue_size, worker_class = parse_args([
:queue_size, nil,
:worker_class, Worker,
], args)