Skip to content

Instantly share code, notes, and snippets.

View altintx's full-sized avatar

Brian altintx

View GitHub Profile
@SCJLabs
SCJLabs / ChatGptZSH.sh
Last active March 14, 2024 14:55
Use ChatGPT API from the terminal (MacOS, ZSH)
# ChatGPT
# Ask ChatGPT questions from your terminal. Results are shown in terminal and markdown is formatted with `glow`.
#
# Requirements:
# 1. In terminal, run: `brew install jq glow`
# 2. Get your free API key here from: https://platform.openai.com/account/api-keys
# 3. Paste in your API key below.
# 3. Paste everything in this gist into your `.zshrc` file. Rename aliases to your liking.
# 4. Remember to source your `.zshrc` file using `source ~/.zshrc` or restart terminal for changes to take effect.
#
@brianarn
brianarn / fibdent.js
Created March 22, 2017 16:45
Fibonacci-based indentation
function topLevel() {
{
{
{
{
{
{
{
// Pretty
}
@peterhellberg
peterhellberg / how-to-install-ruby-oci8.md
Created March 26, 2014 15:39
Install of ruby-oci8 for 10.9/OSX Mavericks

Install of ruby-oci8 for 10.9/OSX Mavericks - step-by-step:

  1. Go here: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
  2. Download the 64bit versions of instantclient-sqlplus, instantclient-sdk, instantclient-basic - the 32bit versions do not work with OSX 10.9
  3. Create directories at /opt/oracle
  4. Unzip instantclient-basic first, move to /opt/oracle (should add a folder - something like /opt/oracle/instantclient_11_2/)
  5. Unzip instantclient-sdk and move its contents to /opt/oracle/instantclient_11_2/
  6. Unzip instantclient-sqlplus and move its contents /opt/oracle/instantclient_11_2/
  7. Open Terminal (if you haven't already) and type...
  8. DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 export DYLD_LIBRARY_PATH
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
@djangofan
djangofan / gist:3113588
Created July 14, 2012 21:50
Cron job script to give a disk space usage alert email
#!/bin/sh
# this script was initially written for Redhat/CentOS
# file is /etc/cron.daily/diskAlert.cron
# requires enabling outgoing sendmail from localhost to a valid
# smtp server, which is usually disabled by default
ADMIN="jausten@adomain.com,another@adomain.com"
THRESHOLD=90
df -PkH | grep -vE '^Filesystem|tmpfs|cdrom|media' | awk '{ print $5 " " $6 }' | while read output;
do
@altintx
altintx / swipe_to_delete.js
Created April 20, 2012 19:26
Swipe to Delete on Sencha Touch 2.0 list
/* Assuming:
* dataview is a { xtype: "list" }
* dataview.itemTpl includes a <div class="deleteplaceholder"></div>
*
* Delete button will disappear as soon as something is touched
*/
dataview.on("itemswipe", function(dataview, ix, target, record, event, options) {
if (event.direction == "left") {
var del = Ext.create("Ext.Button", {
@dhavaln
dhavaln / camera.html
Created March 29, 2012 14:33
Phonegap Camera Capture Example
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo</title>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"/>
<script type="text/javascript" charset="utf-8" src="js/phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
@badsyntax
badsyntax / timeago.js
Created March 26, 2012 13:06
Javascript date time ago
Ext.Date.fuzzy = function(time, local){
(!local) && (local = Date.now());
if (typeof time !== 'number' || typeof local !== 'number') {
return;
}
var
offset = Math.abs((local - time)/1000),
@Yaffle
Yaffle / convertPointFromPageToNode.js
Last active April 30, 2024 03:50
function to get the MouseEvent coordinates for an element that has CSS3 Transforms
/*jslint plusplus: true, vars: true, indent: 2 */
/*
convertPointFromPageToNode(element, event.pageX, event.pageY) -> {x, y}
returns coordinate in element's local coordinate system (works properly with css transforms without perspective projection)
convertPointFromNodeToPage(element, offsetX, offsetY) -> {x, y}
returns coordinate in window's coordinate system (works properly with css transforms without perspective projection)
*/