Skip to content

Instantly share code, notes, and snippets.

View adarshaj's full-sized avatar

Adarsh J adarshaj

View GitHub Profile
@hrishikeshrt
hrishikeshrt / check_attendance.py
Last active February 7, 2020 09:12
Attendance Checker and Reminder for IITK CSE (Kendra and Pingala)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Hrishikesh Terdalkar
Attendance Checker and Reminder for IITK CSE
Checks both on Kendra and Pingala
You can add the command to cronjob by running the command `crontab -e'
and adding the following line at the end. (for checking at 5pm, 8pm, 11pm)
@cheethoe
cheethoe / gist:49d9c1d0003e44423e54a060e0b3fbf1
Last active April 14, 2022 21:01
Rook v0.8.0 device/osd removal
# This will use osd.5 as an example
# ceph commands are expected to be run in the rook-toolbox
1) disk fails
2) remove disk from node
3) mark out osd. `ceph osd out osd.5`
4) remove from crush map. `ceph osd crush remove osd.5`
5) delete caps. `ceph auth del osd.5`
6) remove osd. `ceph osd rm osd.5`
7) delete the deployment `kubectl delete deployment -n rook-ceph rook-ceph-osd-id-5`
8) delete osd data dir on node `rm -rf /var/lib/rook/osd5`
implicit class RichQuery[E, U, C[_]](val underlying: Query[E, U, C]) {
/**
* To group by elements by some columns, say "column1" and "column2", and then pick latest in each group, you
* would normally "ORDER BY column1, column2, created_at DESC" and then "DISTINCT ON (column1, column2)".
* However Slick currently does not support DISTINCT ON. There are a number of alternatives that can be used to
* circumvent this limitation. The following function uses "sub-select method" described here:
* https://robots.thoughtbot.com/ordering-within-a-sql-group-by-clause#sub-select-method
*
* This function only deals with arity 2. You will need to define variations of it for different arities. We
* attempted abstracting over arity but could not get it working.
@galexrt
galexrt / ceph-mon-recovery.md
Last active April 5, 2018 20:20
A WIP doc page on Ceph Mon recovery when running Rook.

Rook <= 0.7.0 mon hostNetwork: true node IP issue

NOTE If you need assistance with steps 3 through 5, let us know on the Rook Slack and we are happy to help you.

WARNING You should not have to go through this section when having hostNetwork: false (or haven't even set it)! WARNING If you have/had multiple Filesystems created, this guide may not work for you because of a bug in Ceph that causes the mons to crash during the "FS Map" assertion.

  1. Scale rook-operator down (e.g. replicas: 0).
  2. Edit all rook-ceph-mon ReplicaSets to have command: ['sleep', '3600'] in the mon container, but copy the other args and command values somewhere safe for each mon.
  3. Exec into the first mon and run: monmap --print /var/lib/rook/rook-ceph-mon-$MON_ID/monmap.
  • Where MON_ID is the ID of the mon you execed into.
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 19, 2024 07:58
Swift Concurrency Manifesto
@wuchengwei
wuchengwei / dataURL to blob and blob to dataURL
Last active May 12, 2024 21:49
dataURL to blob and blob to dataURL
//**dataURL to blob**
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {type:mime});
}
@valfer
valfer / sendPush.txt
Last active April 29, 2024 12:29
Sending Push Notification with HTTP2 (and PHP) see entire post at: http://coding.tabasoft.it/ios/sending-push-notification-with-http2-and-php/
<?php
/**
* @param $http2ch the curl connection
* @param $http2_server the Apple server url
* @param $apple_cert the path to the certificate
* @param $app_bundle_id the app bundle id
* @param $message the payload to send (JSON)
* @param $token the token of the device
* @return mixed the status code (see https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html#//apple_ref/doc/uid/TP40008194-CH101-SW18)
@janeczku
janeczku / user-data.sh
Last active November 18, 2017 02:32
OVH Public Cloud - Cloud-Init bootstrap Failover IP + Docker
#!/bin/sh
cat > /etc/network/interfaces.d/eth0-0.cfg <<EOF
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 178.32.XXX.XXX
netmask 255.255.255.255
broadcast 178.32.XXX.XXX
post-up /sbin/ip route replace default via $(/sbin/ip route | awk '/default/ { print $3 }') dev eth0 src 178.32.XXX.XXX
@fboudra
fboudra / github-issues-to-phabricator-tasks.py
Created May 31, 2015 07:51
Simple python script to import github issues (including comments) to phabricator tasks. It depends on pygithub, arc and requires some basic configuration.
#!/usr/bin/python
import collections
import json
import os
import signal
import sys
import subprocess
# require pygithub installed
from github import Github
@shanechin
shanechin / gist:f97b1f7b766bbffeeddd
Created March 16, 2015 02:39
playing around with kamon-dashboard
while true
do
echo -n "stats.timers.kamon.localhost.system-metric.cpu.cpu-user.mean_99:$(((RANDOM % 10) + 1))|c" | nc -w 1 -u localhost 8125
done