Skip to content

Instantly share code, notes, and snippets.

View csehammad's full-sized avatar
🏠
Working from home

Hammad Abbasi csehammad

🏠
Working from home
View GitHub Profile
@csehammad
csehammad / gist:5d1fd88d6239c9589447a446e02f2149
Created October 13, 2025 09:32
Pure Python CPU Benchmark - Python 3.14t Free-Threading
#!/usr/bin/env python3.14t
"""
Pure Python CPU Benchmark - Python 3.14t Free-Threading
========================================================
Benchmark using PURE PYTHON CPU-intensive operations to prove
true parallelism. Uses operations that hold the GIL in standard
Python but run in parallel with free-threading.
Author: Hammad Abbasi
@csehammad
csehammad / implement_content_moderation_rails.rb
Created August 4, 2023 16:10
Implementing Content Moderation in Ruby on Rails using OpenAI API
require 'http'
OPENAI_API_KEY = 'your-api-key-here'
def moderate_text(input_text)
headers = {
'Content-Type' => 'application/json',
'Authorization' => "Bearer #{OPENAI_API_KEY}"
}
data = { input: input_text }
@csehammad
csehammad / OpenAIContentModeration.cs
Created August 4, 2023 16:08
Implementing Content Moderation in .NET using OpenAI API
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ContentModerationCSharp
{
class Program
{
@csehammad
csehammad / content_moderation_openai.py
Last active August 4, 2023 16:13
Implementing Content Moderation in Python using OpenAI API
import requests
OPENAI_API_KEY = 'your-api-key-here'
def moderate_text(input_text):
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {OPENAI_API_KEY}',
}
data = {'input': input_text}
@csehammad
csehammad / content_moderation_openai.js
Created August 4, 2023 15:58
Implementing Content Moderation in Node.js using OpenAI API
const fetch = require('node-fetch');
const OPENAI_API_KEY = 'your-api-key-here';
async function moderateText(inputText) {
try {
const response = await fetch('https://api.openai.com/v1/moderations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<!-- Include source map for debugging (for other source map options see https://webpack.js.org/configuration/devtool/ ) -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npx webpack --debug --devtool inline-source-map scripts/index.js" />
@csehammad
csehammad / index.js
Last active December 17, 2020 01:22
const { Product, Empty, Result } = require('./stock_pb');
const { StockClient } = require('./stock_grpc_web_pb');
var client = new StockClient(window.location.origin);
var txtName = document.getElementById('name');
var txtCode = document.getElementById('code');
var btnAddProduct = document.getElementById('addProduct');
var trProducts = document.getElementById('trProducts');
syntax = "proto3";
option csharp_namespace = "StockServices.Protos";
package stock;
service Stock {
rpc GetAllProducts(Empty) returns (stream Product);
rpc AddProduct (Product) returns (Result);
}