Skip to content

Instantly share code, notes, and snippets.

View tagrudev's full-sized avatar

Todor Grudev tagrudev

View GitHub Profile
Hydra.getInstance().getClient().post(getActivity(), Fields.GRAPH_CONTACTS_URL, params, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
Crouton.makeText(getActivity(), "Your question was sent successfully.", Style.CONFIRM, Configuration.DURATION_SHORT).show();
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable e, JSONObject response) {
Crouton.makeText(getActivity(), R.string.no_internet_connection, Style.ALERT, Configuration.DURATION_SHORT).show();
}
@tagrudev
tagrudev / fake.java
Created April 1, 2014 12:59
Open Gallery Android
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"content://media/internal/images/media"));
startActivity(intent);
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
Intent.FLAG_ACTIVITY_CLEAR_TOP
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
@tagrudev
tagrudev / want.java
Last active December 31, 2015 17:48
How can I use array for a case value in a switch statement ?
boolean[] values = new boolean[4];
values[0] = true;
values[1] = false;
values[2] = false;
values[3] = true;
switch (values) {
case [true, false, true, false]:
break;
class Log < ActiveRecord::Base
self.table_name = "versions"
has_one :previous_log, :class_name => "Log",
:order => "created_at DESC",
:conditions => proc{ "item_type = #{self.item_type}" }
end
=> NoMethodError: undefined method `item_type' for #<Class:0x7f9f5200c5f0>
@tagrudev
tagrudev / yolo.erb
Last active December 22, 2015 23:29
<%= simple_form_for @menu do |m| %>
<%= m.simple_fields_for :meal do |p| %>
<%= p.input :name %>
<% end %>
<% end %>
public class MapActivity extends SherlockActivity {
private LocationManager locationManager;
Location location;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
}
@tagrudev
tagrudev / CurrentLocationListener.java
Created September 10, 2013 10:54
Locations Locations
public class CurrentLocationListener implements LocationListener{
public static double latitude;
public static double longitude;
@SuppressWarnings("static-access")
@Override
public void onLocationChanged(Location location) {
location.getLatitude();
location.getLongitude();
this.latitude=location.getLatitude();
this.longitude=location.getLongitude();
@tagrudev
tagrudev / yolo.rb
Last active December 22, 2015 09:08
def yolo
a = "WAT"
def frak
a = "WAT2"
end
frak
puts a
end
1.9.3-p194 :001 > a = " yolo"
=> " yolo"
1.9.3-p194 :002 > a.strip
=> "yolo"
1.9.3-p194 :003 >