Skip to content

Instantly share code, notes, and snippets.

@davidmroth
davidmroth / compile_cpuminer-multi.sh
Last active February 25, 2021 00:08
Compile cpuminer-multi for Raspberry Pi
#!/bin/bash
#
# WARNING: CPU MINING IS UNPROFITABLE! (FOR HOBBY / EXPERIMENT / RESEARCH ONLY)
#
# RASPBERRY PI CPUMINER-MULTI SETUP SCRIPT
#
# RASPBERRY PI, DOGE, DOGECOIN, PROHASHING.COM, LITECOIN, MINING
#
@unfulvio
unfulvio / functions.php
Last active July 15, 2021 05:17
WordPress HTML Minification Class to compress HTML (removal of whitespaces, line breaks, new lines, comments). Preserves script comments (if removed might break some javascripts like Google Analytics or Adsense) and IE specific tags.
/* Minifies HTML and removes comments (except IE tags and comments within script tags)
*
* To disable compression of code portions, use '<!--wp-html-compression no compression-->' tag
*
* @see http://forrst.com/posts/Wordpress_Minify_output_HTML-29q
* @see http://www.intert3chmedia.net/2011/12/minify-html-javascript-css-without.html
*/
class WP_HTML_Compression
{
// Settings
@KorvinM
KorvinM / wp-supress-private-posts.php
Last active June 25, 2022 15:20
WordPress: Remove private posts from the main query on the posts page
<?php
/* We can use the pre_get_posts action hook to modify a query before it's run.
* http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts*/
add_action( 'pre_get_posts', 'kvn_rem_pp' );
function kvn_rem_pp($query){
if(current_user_can ('read_private_posts') ){
/*restrict to the posts page main query.
*All other views (eg. category archives) unnaffected
*http://codex.wordpress.org/Function_Reference/is_home
*http://codex.wordpress.org/Function_Reference/is_main_query*/
@davidmroth
davidmroth / .bash_profile
Last active November 11, 2022 01:04
Homebrew Setup Mac M1
# !!! IMPORTANT
# Must point to the correct director or this entire script breaks
eval $(/opt/homebrew/bin/brew shellenv)
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/usr/local/google-cloud-sdk/path.bash.inc' ]; then . '/usr/local/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/usr/local/google-cloud-sdk/completion.bash.inc' ]; then . '/usr/local/google-cloud-sdk/completion.bash.inc'; fi
@saas786
saas786 / gist:2779852
Created May 24, 2012 06:42 — forked from wycks/gist:2315295
Rewrite static theme assets and plugins directory (WordPress)
<?php
// rewrite /wp-content/themes/theme-name/css/ to /css/
// rewrite /wp-content/themes/theme-name/js/ to /js/
// rewrite /wp-content/themes/theme-name/img/ to /img/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
@moaaz-bhnas
moaaz-bhnas / withoutEdgesAndNodes.ts
Last active June 11, 2023 17:04
A function that removes edges and nodes from Shopify Storefront data
function isArray(data: any): Boolean {
return data && data.constructor === Array;
}
function isObject(data: any): Boolean {
return data && data.constructor === Object;
}
function withoutEdgesAndNodes(data: any): any {
let result = Array.isArray(data) ? [] : {};
@tablekat
tablekat / main.ts
Created June 30, 2016 20:24
Making gmail push notifications to webhook
import * as request from 'request';
import * as fs from 'fs';
import * as readline from 'readline';
var google = require('googleapis');
var googleAuth = require('google-auth-library');
/*************** STEPS
- made a project on https://console.cloud.google.com/cloudpubsub/topicList?project=testmabs thing?
@RageshAntony
RageshAntony / chat.py
Created August 1, 2023 12:59
Chat with Documents with Memory using LangChain
import openai
from colorama import Fore
from langchain import PromptTemplate
from langchain.chains import ConversationalRetrievalChain, RetrievalQA
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import TextLoader
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.memory import ConversationBufferMemory
from langchain.schema import SystemMessage
from langchain.text_splitter import RecursiveCharacterTextSplitter
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@kdabir
kdabir / heredoc_json.bash
Last active January 11, 2024 02:25
json in heredoc in bash script alongwith variable substitution
_BUCKET_NAME="foo.example.com"
_POLICY=$(cat <<EOT
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],