Skip to content

Instantly share code, notes, and snippets.

View muayyad-alsadi's full-sized avatar

Muayyad Alsadi muayyad-alsadi

View GitHub Profile
@muayyad-alsadi
muayyad-alsadi / Http.php
Last active August 16, 2019 09:40
proposed solr client
<?php
class Http {
protected $_opt = array(
CURLOPT_USERAGENT=>'Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1',
CURLOPT_HEADER => 0,
CURLOPT_HTTPHEADER=>array('Expect: '),
CURLOPT_FRESH_CONNECT => 0,
CURLOPT_FORBID_REUSE => 0,
CURLOPT_BINARYTRANSFER => 1,
CURLOPT_RETURNTRANSFER => 1,
/* thumbnails alignment bug fix, see https://github.com/twitter/bootstrap/issues/3494 */
.row-fluid .thumbnails [class*="span"] {
margin-right: 2.5641%;
}
.row-fluid .thumbnails [class*="span"]:first-child {
margin-right: 2.5641%;
margin-bottom: 0;
}
/*
// bug fixed
/* thumbnails alignment bug fix, see https://github.com/twitter/bootstrap/issues/3494 */
.row-fluid .thumbnails [class*="span"] {
margin-left: 2.5641%;
}
.row-fluid .thumbnails [class*="span"]:first-child {
margin-left: 2.5641%;
margin-bottom: 0;
}
/*
>>> for n in range(1,13): m=12.0/n; print ".row-fluid .thumbnails span%d { width: %g%%;}" % (n,(100.0 - 2.5642*(m)) / m)
@muayyad-alsadi
muayyad-alsadi / gist:8134064
Created December 26, 2013 13:50
listView with onclick
static class MyViewHolder { ImageView logo; TextView name, foo, bar;}
public View getView (int position, View v, ViewGroup parent) {
MyType item=getItem(position);
MyViewHolder holder;
if (v==null) {
v = adapter.inflater.inflate(R.layout.my_row, null, false);
holder = new MyViewHolder();
holder.logo=(ImageView) v.findViewById(R.id.logo);
holder.name=(TextView) v.findViewById(R.id.name);
@muayyad-alsadi
muayyad-alsadi / declatative-ajax.js
Created December 31, 2013 15:02
declatative-ajax.js
function ajax_load(e){
// styled after bootstrap-ajax < https://github.com/eldarion/bootstrap-ajax
var $e=$(e), src=e.getAttribute('data-src'), data={};
var s,k,$target,f;
var verb=e.getAttribute('data-verb');
if (!verb) verb='get';
if (e.getAttribute('data-params')) {
$.extend(data, $.parseJSON(e.getAttribute('data-params')) );
}
$.ajax({type:verb, url:src,data:data, dataType:'json',
@muayyad-alsadi
muayyad-alsadi / bootstrap-rtl-xtra.css
Created January 8, 2014 14:50
bootstrap-rtl-xtra.css
.pull-start {float:right;}
.pull-end {float:left;}
.text-start {text-align:right;}
.text-end {text-align:left;}
.media > .pull-start {margin-left: 10px;}
.media > .pull-end {margin-right: 10px;}
.carousel-control.prev { right: 15px; left: auto; }
.carousel-control.next { left: 15px; right: auto; }
@muayyad-alsadi
muayyad-alsadi / primes.php
Last active August 29, 2015 14:03
primes with php
<?php
function get_primes($n) {
$primes=array();
$compo=array();
for($i=2;$i<$n;++$i) $compo[$i]=false;
for($i=2;$i<$n;++$i) {
if ($compo[$i]) continue;
$primes[]=$i;
for($j=$i*2;$j<$n;$j+=$i) $compo[$j]=true;
@muayyad-alsadi
muayyad-alsadi / primes.py
Created July 5, 2014 11:49
do not benchmark yield
import time
def get_primes(n):
compo=set()
for i in xrange(2, n):
if i in compo: continue
yield i
compo.update(xrange(i*2, n,i))
def benchmark(f, n):
@muayyad-alsadi
muayyad-alsadi / PrimesTest.java
Created July 5, 2014 13:06
primes iterator and iterable
import java.util.*;
/*
you can use it like this
PrimesIterator primes=new PrimesIterator(10000);
while(primes.hasNext()){
System.out.println(primes.next());
}
*/
class PrimesIterator implements Iterator<Integer> {
@muayyad-alsadi
muayyad-alsadi / primes.py
Created July 5, 2014 14:50
primes in python
import time
def get_primes(n):
compo=set()
for i in xrange(2, n):
if i in compo: continue
yield i
compo.update(xrange(i*2, n,i))
def benchmark(f, n):