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
/** | |
* Use as `"#fff".parseColor()` | |
*/ | |
fun String.parseColor() = Color.parseColor(this) | |
/** | |
* Use as `16.spToPx(context)` or `16.5.spToPx(context)` | |
*/ | |
fun Number.spToPx(context: Context) = TypedValue.applyDimension( | |
TypedValue.COMPLEX_UNIT_SP, this.toFloat(), context.resources.displayMetrics).toInt() |
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
import android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.Path; | |
import android.graphics.drawable.Drawable; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
import android.view.ViewTreeObserver; |
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
import android.annotation.TargetApi; | |
import android.content.Context; | |
import android.os.Build; | |
import android.text.SpannableStringBuilder; | |
import android.text.method.LinkMovementMethod; | |
import android.text.style.ClickableSpan; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewTreeObserver; | |
import android.widget.TextView; |
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
struct lua_function functions[] = { | |
{"get_contact_list", lq_contact_list, { lfp_none }}, | |
{"get_dialog_list", lq_dialog_list, { lfp_none }}, | |
{"rename_chat", lq_rename_chat, { lfp_chat, lfp_string, lfp_none }}, | |
{"send_msg", lq_msg, { lfp_peer, lfp_string, lfp_none }}, | |
{"send_typing", lq_send_typing, { lfp_peer, lfp_none }}, | |
{"send_typing_abort", lq_send_typing_abort, { lfp_peer, lfp_none }}, | |
{"send_photo", lq_send_photo, { lfp_peer, lfp_string, lfp_none }}, | |
{"send_video", lq_send_video, { lfp_peer, lfp_string, lfp_none }}, | |
{"send_audio", lq_send_audio, { lfp_peer, lfp_string, lfp_none }}, |
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
I had to change this in the telegram CLI to make it work: | |
https://github.com/vedant1811/tg/commit/e068c2549f2f155ba9c40bd7cee8b076d03b417f |
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
# from http://stackoverflow.com/a/2439293/1396264 | |
def self.find_or_create_by_name(*args) | |
puts args.inspect | |
options = args.extract_options! | |
options[:name] = args[0] if args[0].is_a?(String) | |
case_sensitive = options.delete(:case_sensitive) | |
conditions = case_sensitive ? ['name = ?', options[:name]] : | |
['UPPER(name) = ?', options[:name].upcase] | |
where(conditions).first || create(options) | |
end |
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 vedant.olahackathon; | |
import android.util.Log; | |
import org.codehaus.jackson.JsonFactory; | |
import org.codehaus.jackson.JsonGenerator; | |
import org.codehaus.jackson.map.DeserializationConfig; | |
import org.codehaus.jackson.map.ObjectMapper; | |
import java.io.FileWriter; |
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
import com.android.volley.NetworkResponse; | |
import com.android.volley.ParseError; | |
import com.android.volley.Response; | |
import com.android.volley.toolbox.HttpHeaderParser; | |
import com.android.volley.toolbox.JsonRequest; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; |
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
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.AdapterView; | |
/** | |
* Used this to differentiate between user selected and prorammatically selected | |
* Call {@link Spinner#programmaticallySetPosition} to use this feature. | |
* Created by vedant on 6/1/15. |
NewerOlder