This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Boolean loading_data = false; | |
private Boolean load_data = false; | |
private OnScrollListener mScrollListener = new OnScrollListener() { | |
@Override | |
public void onScrollStateChanged(AbsListView view, int scrollState) { | |
if(load_data && !loading_data){ | |
startLoadingData(); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="{{request.path}}" method="post" enctype="multipart/form-data" id="upload_form"> | |
{%csrf_token%} | |
<input type="text" name="name" id="name" value="{{request.POST.name}}"/> | |
<input type="text" name="categorie" id="categorie" value="{{request.POST.categorie}}"/> | |
<div class="file_inputs" id="file_inputs"> | |
<input type="file" name="docfile" id="id_docfile"> | |
</div> | |
<input type="submit" value="Upload"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "admin/base.html" %} | |
{% load i18n %} | |
{% block title %}{{ title }} | {% trans 'SOME TITLE' %}{% endblock %} | |
{% block branding %} | |
<h1 id="site-name">{% trans 'SOME TITLE' %}</h1> | |
{% endblock %} | |
{% block extrahead %} | |
<style type="text/css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/3208160/how-to-generate-an-hmac-in-java-equivalent-to-a-python-example | |
import org.apache.commons.codec.binary.Hex; | |
import javax.crypto.Mac; | |
import javax.crypto.spec.SecretKeySpec; | |
public static class HashingUtility { | |
public static String HMAC_MD5_encode(String key, String message) throws Exception { | |
SecretKeySpec keySpec = new SecretKeySpec( | |
key.getBytes(), | |
"HmacMD5"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#generate random string X is lenght of it | |
import random,string | |
''.join(random.sample(string.ascii_lowercase+string.ascii_uppercase+string.digits, X)) | |
# check only for particular set of strings exists or not. | |
import re | |
reg = re.compile('^[a-zA-Z0-9_]+$') | |
string = "SomeString___" | |
string_fail = "SomeString..3+__)" | |
reg.match(string) # <- returns a match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//youtube url https://www.youtube.com/watch?v=id <- video_id is this one. | |
//for thumbnail images use this url | |
//http://img.youtube.com/vi/{{video_id}}/0.jpg | |
//0.jpg is always hd thumbnail image .. 1.jpg, 2.jpg 3.jpg is for thumbnail 1,2,3 | |
function getYouTubeInfo(video_id) { | |
$.ajax({ | |
url: "http://gdata.youtube.com/feeds/api/videos/"+video_id+"?v=2&alt=json", | |
dataType: "jsonp", | |
success: function (data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.w4rlock.cacheManager; | |
import java.io.BufferedWriter; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileReader; | |
import java.io.FileWriter; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.nio.MappedByteBuffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="{{request.path}}" method="post" enctype="multipart/form-data" id="upload_form"> | |
{%csrf_token%} | |
<div class="text_inputs" id="text_inputs"> | |
<input type="text" name="doctext" id="id_doctext"> | |
</div> | |
<input type="submit" value="Upload"> | |
</form> | |
<a href="#" onClick="addformelement()" >add new item</a> | |
<script type="text/javascript"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# don't remember from where i got this | |
from django.contrib.contenttypes.models import ContentType | |
def run(): | |
def do(Table): | |
if Table is not None: | |
table_objects = Table.objects.all() | |
for i in table_objects: | |
i.save(using='slave') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.emil.android.util; | |
import android.content.Context; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.telephony.TelephonyManager; | |
/** | |
* Check device's network connectivity and speed | |
* @author emil http://stackoverflow.com/users/220710/emil |