Skip to content

Instantly share code, notes, and snippets.

View aliirz's full-sized avatar
🦄
People over Processes

Ali Raza aliirz

🦄
People over Processes
View GitHub Profile
@aliirz
aliirz / tictactoe.py
Created March 10, 2019 08:24 — forked from eaorak/tictactoe.py
Python - TicTacToe Game
#!/usr/bin/python3
# Simple TicTacToe game in Python - EAO
import random
import sys
board=[i for i in range(0,9)]
player, computer = '',''
# Corners, Center and Others, respectively
moves=((1,7,3,9),(5,),(2,4,6,8))
class SmileApi
require 'uri'
def get_session
user_name = "username here"
password = "password here"
data = File.read("http://api.smilesn.com/session?username="+username+"&password="+password)
data=JSON.parse(data)
sessionid=data.sessionid
file2 = File.open('session.txt', 'w')
MAX_DISTANCE_AWAY_IN_KM = 100.0
RAD_PER_DEG = 0.017453293
Rmiles = 3956 # radius of the great circle in miles
Rkm = 6371 # radius in kilometers, some algorithms use 6367
Rfeet = Rmiles * 5282 # radius in feet
Rmeters = Rkm * 1000 # radius in meters
def haversine_distance( lat1, lon1, lat2, lon2 )
dlon = lon2 - lon1
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* */
/* Simple node js module to get distance between two coordinates. */
/* */
/* Code transformed from Chris Veness example code - please refer to his website for licensing */
/* questions. */
/* */
/* */
/* Latitude/longitude spherical geodesy formulae & scripts (c) Chris Veness 2002-2011 */
/* - www.movable-type.co.uk/scripts/latlong.html */
<!-- using the truncate filter -->
{% for post in site.posts limit:10 %}
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
<span class="post-date">{{ post.date | date: "%B %d, %Y" }}</span>
{% if post.content.size > 2000 %}
{{ post.content | truncatewords: 300 }} <!-- bad! content gives you rendered html and you will truncate in the middle of a node -->
<a href="{{ post.url }}">read more</a>
{% else %}
{{ post.content }}
{% endif %}
@aliirz
aliirz / toast.js
Last active December 11, 2015 03:18 — forked from kamranzafar/toast.js
var toast=function(heading, msg){
$("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h3>"+heading+"</h3><p>"+msg+"</p></div>")
.css({ display: "block",
opacity: 0.90,
position: "fixed",
padding: "7px",
"text-align": "center",
width: "270px",
left: ($(window).width() - 284)/2,
top: $(window).height()/2 })
@aliirz
aliirz / twitter.m
Created May 23, 2012 11:04 — forked from vhbit/twitter.m
Follow us on Twitter button for iOS
- (BOOL)openTwitterClientForUserName:(NSString*)userName {
NSArray *urls = [NSArray arrayWithObjects:
@"twitter:@{username}", // Twitter
@"tweetbot:///user_profile/{username}", // TweetBot
@"echofon:///user_timeline?{username}", // Echofon
@"twit:///user?screen_name={username}", // Twittelator Pro
@"x-seesmic://twitter_profile?twitter_screen_name={username}", // Seesmic
@"x-birdfeed://user?screen_name={username}", // Birdfeed
@"tweetings:///user?screen_name={username}", // Tweetings
@"simplytweet:?link=http://twitter.com/{username}", // SimplyTweet
@aliirz
aliirz / README.md
Created December 7, 2011 14:37 — forked from napcs/README.md
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup