Skip to content

Instantly share code, notes, and snippets.

@teleclient
teleclient / gist:7ae15dce0542cd881c5c0b74252c3003
Created September 18, 2020 20:57 — forked from rlemon/gist:1780212
PHP get CPU information from /proc/stat
<?php
/* Gets individual core information */
function GetCoreInformation() {
$data = file('/proc/stat');
$cores = array();
foreach( $data as $line ) {
if( preg_match('/^cpu[0-9]/', $line) )
{
$info = explode(' ', $line );
$cores[] = array(
@ybagheri
ybagheri / emoji.php
Created May 21, 2020 04:25
all emoji as array with native value.
<?php
$emoji =[
'😀',
'😃',
'😄',
'😁',
'😆',
'😅',
'🤣',
'😂',
@ybagheri
ybagheri / forward.php
Created January 2, 2020 11:12
Telegram api bot forward forwardMessage from a channel to another.
<?php
$token = YOUR_BOT_TOKEN;
//your bot must be admin of both channel.
$original_from_chat_id = ORIGINAL_CHAT_ID; // like this -1001122688109
$target_chat_id = TARGET_CHAT_ID; // like this -1001131688104
@xmeng1
xmeng1 / wsl2-network.ps1
Created July 14, 2019 06:50
WSL2 Port forwarding port to linux
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@ybagheri
ybagheri / madelineproto_login_html.php
Last active October 10, 2020 08:31
madelineproto login with html
<?php
//here is composer.json
// {
// "require": {
// "ybagheri/easyhelper": "dev-master",
// "ybagheri/easytelegram": "dev-master",
// "james-heinrich/getid3": "^1.9",
// "josegonzalez/dotenv": "dev-master",
// "ybagheri/strfun": "dev-master"
// },
@akehrer
akehrer / sqlite_to_json.sql
Created January 9, 2018 19:58
SQLite Results as JSON using the SQLite JSON1 extension
-- When SQLite is compiled with the JSON1 extensions it provides builtin tools
-- for manipulating JSON data stored in the database.
-- This is a gist showing SQLite return query data as a JSON object.
-- https://www.sqlite.org/json1.html
-- An example table with some data
CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL,
full_name TEXT NOT NULL,
email TEXT NOT NULL,
@yi-jiayu
yi-jiayu / count_messages.py
Last active January 6, 2025 16:24
Using Telethon and the Telegram API to count the number of messages in each of your recent conversations
from telethon import TelegramClient
from telethon.errors.rpc_errors_401 import SessionPasswordNeededError
# (1) Use your own values here
api_id = 17349
api_hash = '344583e45741c457fe1862106095a5eb'
phone = 'YOUR_NUMBER_HERE'
username = 'username'
@Ocramius
Ocramius / README.md
Last active January 22, 2024 00:09
`__invoke` vs `function` vs `Closure`
@bubba-h57
bubba-h57 / closeConnection.php
Created January 14, 2015 21:39
Easy way to close connections to the browser and continue processing on the server.
<?php
/**
* Close the connection to the browser but continue processing the operation
* @param $body
*/
public function closeConnection($body, $responseCode){
// Cause we are clever and don't want the rest of the script to be bound by a timeout.
// Set to zero so no time limit is imposed from here on out.
set_time_limit(0);
@DragonBe
DragonBe / Product.php
Created March 28, 2014 13:21
Example usage for ArrayAccess interface
<?php
class Product implements ArrayAccess
{
protected $_productId;
protected $_title;
protected $_price;
protected $_arrayAccess;
public function __construct($data = null)