Skip to content

Instantly share code, notes, and snippets.

View mage1k99's full-sized avatar
🏠
Working from home

Magesh Babu mage1k99

🏠
Working from home
View GitHub Profile
@MaTriXy
MaTriXy / NetUtils.kt
Created November 14, 2017 12:47
Get Local IP Address in kotlin
private fun getLocalIpAddress(): String? {
try {
val wifiManager: WifiManager = context?.getSystemService(WIFI_SERVICE) as WifiManager
return ipToString(wifiManager.connectionInfo.ipAddress)
} catch (ex: Exception) {
Log.e("IP Address", ex.toString())
}
@javilobo8
javilobo8 / download-file.js
Last active October 27, 2024 09:15
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@matthewjberger
matthewjberger / instructions.md
Last active November 7, 2024 17:51
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@fgilio
fgilio / axios-catch-error.js
Last active August 15, 2024 01:45
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@ahmadshah
ahmadshah / componentA.vue
Created June 24, 2016 07:49
Vuejs Event Emitter
<template>
<button @click="emitEvent">EVENT</button>
</template>
<script>
import { EV } from './events'
export default {
methods: {
emitEvent() {
@standa
standa / loop.sh
Created April 29, 2016 09:59
Infinite loop internet speed test
# download speedtest python script
# wget https://raw.githubusercontent.com/rsvp/speedtest-linux/master/speedtest
# wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
while true; do ./speedtest --log; sleep 900; done