Skip to content

Instantly share code, notes, and snippets.

View karimkawambwa's full-sized avatar
🙃
doing something

Karim karimkawambwa

🙃
doing something
  • Bagamoyo, Tanzania
View GitHub Profile
@karimkawambwa
karimkawambwa / gist:1a6a3c4cae11dd99d12ad511e5936da4
Created May 2, 2024 18:30
arusha press club migration script
<?php
function post_exists_by_title($title) {
global $wpdb;
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'post' AND post_status = 'publish' LIMIT 1", $title);
return $wpdb->get_var($query);
}
function set_featured_image($post_id, $image_url) {
if (empty($image_url)) return;
<?php
function post_exists_by_title($title) {
global $wpdb;
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'post' AND post_status = 'publish' LIMIT 1", $title);
return $wpdb->get_var($query);
}
function fetch_full_post_content($url) {
if (!$url) return 'No content found';
// From https://bitbucket.org/atlassian/atlaskit-mk-2/raw/4ad0e56649c3e6c973e226b7efaeb28cb240ccb0/packages/core/select/src/data/countries.js
export const countries = [
{ code: "AD", label: "Andorra", phone: "376" },
{ code: "AE", label: "United Arab Emirates", phone: "971" },
{ code: "AF", label: "Afghanistan", phone: "93" },
{ code: "AG", label: "Antigua and Barbuda", phone: "1-268" },
{ code: "AI", label: "Anguilla", phone: "1-264" },
{ code: "AL", label: "Albania", phone: "355" },
{ code: "AM", label: "Armenia", phone: "374" },
{ code: "AO", label: "Angola", phone: "244" },

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@karimkawambwa
karimkawambwa / sofa-api-keystone-js
Created March 15, 2021 20:00
Convert KeystoneJS v5 GraphQL operations into REST routes using sofa-api https://github.com/Urigo/sofa
useSofa({
schema,
basePath: "/rest",
context: ({ req }) => {
// console.log(req.url, req.originalUrl);
// console.log("Here");
},
execute: ({ source, variableValues }) => {
return keystone.executeGraphQL({
query: source,
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@karimkawambwa
karimkawambwa / README.md
Created October 21, 2020 00:48 — forked from so0k/README.md
Alpine-shell

Getting an Alpine shell

Often usefull for in-cluster debugging.

$ kubectl run --generator=run-pod/v1 --image=alpine:3.5 -it alpine-shell -- /bin/sh

detach (without killing the container):

@karimkawambwa
karimkawambwa / Industries.csv
Created September 14, 2020 18:11 — forked from mbejda/Industries.csv
Compiled list of industries.
Industry
Accounting
Airlines/Aviation
Alternative Dispute Resolution
Alternative Medicine
Animation
Apparel/Fashion
Architecture/Planning
Arts/Crafts
Automotive
@karimkawambwa
karimkawambwa / kubectl.md
Created August 28, 2020 17:32 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
{
"100": {
"brief": "Continue",
"extended": "The server has received the request headers, and the client should proceed to send the request body"
},
"101": {
"brief": "Switching Protocols",
"extended": "The requester has asked the server to switch protocols"
},
"103": {