Skip to content

Instantly share code, notes, and snippets.

View mrcat323's full-sized avatar

Mr CaT mrcat323

View GitHub Profile
<?php
$arr = array(
0 => array("href" => "google.com", "text" => "Google"),
1 => array("href" => "ya.ru", "text" => "Yandex"),
2 => array("href" => "google.com", "text" => "Google RU"),
3 => array("href" => "google.com", "text" => "Google"),
);
$str = array();
$some = array();
<?php
mb_internal_encoding('UTF-8');
$input = 'привет, мир. я программист PHP. это правда! не вру!';
function text($input)
{
return preg_replace_callback('#((?:[.!?]|^)\s*)(\w)#us', function($matches) {
return $matches[1] . mb_strtoupper($matches[2]);
}, $input);
<?php
$text = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.';
function getWordsCountEndsWith($letter, $text)
{
return preg_match_all('#' . preg_quote($letter, '#') . '\b#usi', $text);
}
function getWordsCountStartsWith($letter, $text)
@mrcat323
mrcat323 / db.php
Created May 17, 2017 12:21
lil' db class
<?php
class DB {
public static function connectDb()
{
$host = 'localhost';
$dbname = 'hhahh';
$user = 'hhahh';
$password = 'hhahh';
$db = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
@mrcat323
mrcat323 / sum.php
Last active January 8, 2020 10:55
Sums of Digits, algorithm and code
<?php
# Sums of Digits
# Algorythm and code
# By Mr CaT
# Copyright (c) 2017
function fix($a,$b,$c)
{
global $d; # Our global var, will be $d
$d = $a * $b + $c; # D is a * b and plus c
@mrcat323
mrcat323 / bot.php
Created June 10, 2017 06:50
Telekhram bot
<?php
$token = '';
$last_offset_filename = 'last_offset.txt';
$last_offset = file_exists($last_offset_filename) ? file_get_contents($last_offset_filename) : '0';
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_HEADER => 0,
@mrcat323
mrcat323 / digits.py
Created December 14, 2017 17:30
Sums of digits
#!/usr/bin/env python3
# Function of sums of digits
def solve(a,b,c):
d=a*b+c
result=list(map(int,str(d))
@mrcat323
mrcat323 / store.py
Created December 20, 2017 09:09 — forked from jbub/store.py
from kombu import Connection, Exchange, Queue
from kombu.pools import connections
class AmqpStore(Store):
name = 'amqp'
def configure(self, cfg, logger):
url = cfg.var('ITEM_STORE_URL')
self.logger = logger
@mrcat323
mrcat323 / self_exploit.py
Created January 11, 2018 07:47 — forked from WGH-/self_exploit.py
Self-exploiting exploit
#!/usr/bin/python2
import sys
from pwn import *
def find_libc_path_and_offset():
with open("/proc/self/maps") as f:
for line in f:
line = line.strip()
@mrcat323
mrcat323 / pwn.py
Created January 11, 2018 07:48
Quadratically exploit
#!/usr/bin/env python3
import socket, sys, re
from time import sleep
s = socket.socket()
s.connect((sys.argv[1], 6666)) # connect to service, ip in first script arg
# Recv until string occurs
def recv_until(s, st):
buf = ''
while True: