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
default: &default | |
adapter: postgresql | |
encoding: unicode | |
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
timeout: 5000 | |
host: localhost | |
username: rails | |
password: rails | |
development: |
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
def flatten_array(array) | |
result = [] | |
array.each do |e| | |
if e.is_a? Array | |
result += flatten_array e | |
else | |
result << e | |
end | |
end | |
result |
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
def catch(arr, k) | |
ps = 0 | |
ts = 0 | |
count = 0 | |
arr.each do |e| | |
if e == 'T' | |
if ps > 0 | |
ps -= 1 | |
count += 1 |
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
def balance(string) | |
offset = 0 | |
swaps = 0 | |
string.each_char do |c| | |
if c == '[' | |
if offset > 0 | |
swaps += offset | |
end | |
offset -= 1 | |
else |
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
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
# 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; |
NewerOlder