Skip to content

Instantly share code, notes, and snippets.

View stnc's full-sized avatar
🎯
Focusing

TUNC Sam stnc

🎯
Focusing
View GitHub Profile
@stnc
stnc / microgpt.py
Created February 18, 2026 01:31 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@stnc
stnc / main.go
Created February 5, 2026 11:51
csv go
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
"reflect"
@stnc
stnc / table.php
Created July 1, 2025 05:38
php array_chunk — Split an array into chunks / used array chunk with html table
<table>
<colgroup>
<col width="50">
<col width="50">
<col width="50">
<col width="50">
@stnc
stnc / list all categories.sql
Last active February 27, 2025 01:04
Mysql query to list all WordPress posts with categories and tags
#How to list all categories and their IDs using SQL query?
SELECT t.name, t.slug, t.term_id, x.count, tt.name AS parent_name FROM wp_term_taxonomy AS x
INNER JOIN wp_terms AS t ON t.term_id = x.term_id
LEFT JOIN wp_terms AS tt ON tt.term_id = x.parent
WHERE taxonomy = 'category'
ORDER BY t.name
@stnc
stnc / sort-photos-by-month.py
Created September 30, 2024 04:56 — forked from pkkid/sort-photos-by-month.py
Sort Photos by Month
#!/usr/bin/python3
"""
Sort Photos by Month.
install python3-pil
"""
import logging, datetime
import argparse, os, sys
import hashlib
from PIL import Image
@stnc
stnc / depent.php
Created August 12, 2024 02:17
On a single post page, it gives the categories to which the page is affiliated.
<?php
// $terms = wp_get_post_terms( get_the_id(), 'topics', array( 'orderby' => 'term_order' ));
$terms = wp_get_post_terms( get_the_id(), 'category', array( 'orderby' => 'term_order' ));
echo "<pre>";
print_r( $terms);
get_permalink($id);
@stnc
stnc / cat.php
Last active August 12, 2024 02:14
Get all categories and posts in those categories
<?php
//https://wordpress.stackexchange.com/questions/43426/get-all-categories-and-posts-in-those-categories
$args = array(
'posts_per_page' => -1
);
$query = new WP_Query($args);
@stnc
stnc / example1.php
Last active August 8, 2024 19:41
How to get all registered menus in wordress #menu #WordPress
<?php $menus = get_registered_nav_menus();
foreach ( $menus as $location => $description ) {
echo $location . ': ' . $description . '<br />';
}
@stnc
stnc / adb.css
Created July 22, 2024 19:20
wordpress uploader trigger
span.delete,
span.delete,
span.delete_media {
position: absolute;
top: 0;
right: 0;
display: none;
cursor: pointer;
z-index: 1;
color: #555555;
@stnc
stnc / 1good.html
Last active June 10, 2024 07:46
Knockout example
<!doctype html>
<html class="no-js" lang="en-US">
<head>
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/knockout/knockout-3.5.0.js"></script>
<!-- <script src="model.js" type="text/javascript"></script>
-->
<script>