Skip to content

Instantly share code, notes, and snippets.

View ging-dev's full-sized avatar
😘
Còn sống nè

Thanh Trần ging-dev

😘
Còn sống nè
  • Việt Nam Tp. Thái Nguyên, Thái Nguyên
View GitHub Profile
@mlabonne
mlabonne / finetune_llama2.py
Last active January 22, 2025 15:02
Easy Llama 2 fine-tuning script (📝 Article: https://tinyurl.com/finetunellama2)
# Based on younesbelkada/finetune_llama_v2.py
# Install the following libraries:
# pip install accelerate==0.21.0 peft==0.4.0 bitsandbytes==0.40.2 transformers==4.31.0 trl==0.4.7 scipy
from dataclasses import dataclass, field
from typing import Optional
import torch
from datasets import load_dataset
from transformers import (
@DaveLiddament
DaveLiddament / PHP generics notation for static analysis.md
Created October 30, 2022 14:13
PHP generics notation for static analysis

Notation for generics to PHP: #<>

Disclaimer: I assume someone has already suggested this and there are good reasons it hasn't happened!

Inspired by a conversation with @pronskiy after my talk "PHP Generics Today (Almost)" at IPC Munich

Examples:

class Queue #
<?php
function file_get_contents(string $pathname): string
{
$result = '';
$fp = fopen($pathname, 'rb');
while (!feof($fp)) {
$chunk = 1024;
Fiber::getCurrent() && ($chunk = (Fiber::suspend() ?: 1024));
@SerafimArts
SerafimArts / example-1.php
Last active April 17, 2022 10:47
phpwtf-1
<?php
$variable = 23;
[$query, $params] = sql(fn() => <<<SQL
SELECT * FROM users WHERE id = ${yield $variable} OR id = ${yield 42}
SQL);
var_dump($query, $params);
//
@spaze
spaze / find-cve-2020-15227.sh
Last active April 10, 2025 06:26
CVE-2020-15227 nette/application RCE in-place patch
#!/bin/bash
# Find files in CVE-2020-15227 nette/application issue
# by @spazef0rze
# Run with `bash find-cve-2020-15227.sh`, works on Linux, FreeBSD, tested on Ubuntu 18.04, FreeBSD 11.4
# This is a universal finder for all affected versions.
# Requirements: find, grep, bash (might work with your default shell but YMMV)
# The fixes:
@eusonlito
eusonlito / float2hex.php
Last active December 5, 2021 14:42
Convert a HEXADECIMAL value into a FLOAT
<?php declare(strict_types=1);
/**
* @param float $value
*
* @return string
*/
function float2hex(float $value): string
{
$pack = pack('f', $value);
$hex = '';
@stevelandeyasana
stevelandeyasana / hide_native_tabs.css
Created March 19, 2019 19:34
CSS to hide Firefox's tab bar but keep macOS window buttons (close/minimize/maximize)
/* add to your userChrome.css */
#TabsToolbar {
visibility: collapse;
overflow: visible;
}
#TabsToolbar > * {
visibility: collapse;
}
@mirkorap
mirkorap / symfony4-fos-oauth-server-bundle.md
Last active February 22, 2024 14:51
Basic examples how to implement a REST API with Symfony 4 + FOSRestBundle + FOSUserBundle + FOSOauthServerBundle with all oauth2 code flow
@fesor
fesor / ContainerReturnTypePlugin.php
Last active July 28, 2022 13:50
Phan plugins for Symfony and Doctrine
<?php
use Phan\CodeBase;
use Phan\Language\Context;
use Phan\Language\UnionType;
use Phan\PluginV2\ReturnTypeOverrideCapability;
use Phan\Language\Element\Method;
use Phan\PluginV2;
use \Phan\Language\FQSEN\FullyQualifiedClassName;
use Phan\Language\Element\Clazz;
@imath
imath / tickets.php
Last active August 5, 2024 13:19
Using WP Statuses for custom Post Types.
<?php
/**
* Using WP Statuses for custom Post Types.
*
* @link http://github.com/imath/wp-statuses
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;