Skip to content

Instantly share code, notes, and snippets.

View sidward35's full-sized avatar

Siddharth Mathur sidward35

View GitHub Profile
@sidward35
sidward35 / Audio setup.md
Last active June 16, 2017 22:24
AlexaPi Troubleshooting

Setting up your devices

If you want to change your playback / recording device (also because the default setting doesn't work for you), you can do that in the configuration file. If you installed into /opt as recommended, it is /etc/opt/AlexaPi/config.yaml. If you installed elsewhere, the file config.yaml is in your AlexaPi/src directory.

You may need to adjust the volume and/or input gain for the microphone, you can do this with alsamixer. Once the adjustments have been made, you can save the settings using alsactl store.

Checking if your system audio works

  1. To test playback, run aplay /usr/share/sounds/alsa/Front_Center.wav
  2. To rest recording, run
@sidward35
sidward35 / PrintPi.cpp
Last active July 13, 2017 02:42
C++ Print Pi
#include <iostream>
#include <math.h>
int main(){
double x=sqrt(12)*(1-(1/(3*pow(3,1)))+(1/(5*pow(3,2)))-(1/(7*pow(3,3)))+(1/(9*pow(3,4)))-(1/(11*pow(3,5)))+(1/(13*pow(3,6)))-(1/(15*pow(3,7)))+(1/(17*pow(3,8))));
std::cout<<"PI estimation\n";
std::cout<<"Estimation of PI without precision setting is "<<x<<"\n";
printf("Estimation PI shown with 12 decimal fraction digit is %.12f\n", x);
std::cout<<"PI value in cmath library is "<<M_PI<<"\n";
return 0;
}
@sidward35
sidward35 / MainActivity.java
Last active January 2, 2020 06:04
Android Button OnClickListener
Button button = findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//some stuff
}
});
@sidward35
sidward35 / MainActivity.java
Created July 17, 2017 01:42
Android make TextView scrollable
textView.setMovementMethod(new ScrollingMovementMethod());
@sidward35
sidward35 / MainActivity.java
Created July 17, 2017 23:55
Android open URLs in default browser
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
@sidward35
sidward35 / MainActivity.java
Created July 18, 2017 10:23
Android make Toast message
Toast.makeText(getApplicationContext(), "Image downloaded!", Toast.LENGTH_SHORT).show();
@sidward35
sidward35 / MainActivity.java
Last active July 20, 2017 04:44
Android AlertDialog with EditText
final EditText input = new EditText(MainActivity.this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
new AlertDialog.Builder(MainActivity.this)
.setTitle("New Playlist")
.setPositiveButton("Create", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
@sidward35
sidward35 / MainActivity.java
Created July 20, 2017 04:51
Android add 'settings' button on NavBar
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
@sidward35
sidward35 / AndroidManifest.xml
Last active January 2, 2020 10:20
Android read/write to file
<manifest>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application>
...
</application>
</manifest>
@sidward35
sidward35 / instructions.md
Last active April 19, 2024 21:04
Using a PS3 EyeToy with the Raspberry Pi

Having heard about the new camera driver built into the kernel of the new Raspbian OS image, I decided to have a play, using my PS3 EyeToy camera. The steps below are based on this forum thread, with some changes to reflect my own experience. The Raspberry Pi supports a number of cameras, not just the EyeToy, so if you have a spare one lying around, give it a go.

  1. Install the ‘motion’package:sudo apt-get install motion
  • This should automatically install the required ‘ffmpeg’ package – if not you can just do sudo apt-get install ffmpeg.
  1. Edit the config file:sudo nano /etc/motion/motion.conf
  • To enable daemon mode (so you can run the software in the background without it tying up your terminal):daemon on