Skip to content

Instantly share code, notes, and snippets.

View Chris-Gillis's full-sized avatar

Christopher Gillis Chris-Gillis

View GitHub Profile
@Chris-Gillis
Chris-Gillis / radio_group_layout.xml
Last active December 20, 2015 19:38
RadioGroup Layout
<RadioGroup android:id="@+id/radioGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:background="@color/MidnightBlue"
>
<RadioButton android:id="@+id/radioButtonAll"
style="@style/RadioButtonStyle"
android:text="All"
<style name="RadioButtonStyle">
<item name="android:textColor">@android:color/white</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:background">@color/Turquoise</item>
<item name="android:paddingLeft">45dp</item>
<item name="android:layout_margin">5dp</item>
<item name="android:layout_weight">1</item>
</style>
mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup);
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
if(checkedId == R.id.radioButtonAll)
{
mPlacesListView.setAdapter(new KFPlaceAdapter(mActivity, allPlaces));
}
@Chris-Gillis
Chris-Gillis / best_catch_ever.java
Created August 9, 2013 02:42
Good use of a try-catch
try
{
// Some code that can fail
}
catch(NumberFormatException e)
{
Log.v(TAG, "User entered invalid data: carbs - " + carbsString + " fiberString - " + fiberString);
// I feel dirty for this hack
mCarbsAmountEditText.removeTextChangedListener(mCarbsTextWatcher);
@Chris-Gillis
Chris-Gillis / auto_publish.sh
Created August 10, 2013 15:18
Script to automatically publish draft to repository
git pull
git add .
git add -u
git commit -m "Automatic Draft Commmit"
git push origin master
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {
@Chris-Gillis
Chris-Gillis / palindrome.hs
Last active August 29, 2015 14:03
Palindrome in Haskell
palindrome :: Eq a => [a] -> Bool
palindrome [] = True
palindrome (x:[]) = True
palindrome (x:_:y:[]) = x == y
palindrome xs | head xs /= last xs = False
| head xs == last xs = palindrome $ stripFirstAndLast xs
where stripFirstAndLast ys = tail $ reverse $ tail $ reverse ys
@Chris-Gillis
Chris-Gillis / component.go
Last active February 23, 2024 02:49
Visual Studio Code config to get TailwindCSS autocomplete in Gomponents classes
import (
. "github.com/maragudk/gomponents/html"
)
func HeaderView() g.Node {
component := Div(Class("/* inside here you get tailwind autocomplete */"))
return component
}