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 April 9, 2024 12:01
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 May 19, 2024 02:31
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 April 11, 2024 19:02
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