Skip to content

Instantly share code, notes, and snippets.

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

mohammad ali alidevhere

🏠
Working from home
View GitHub Profile

Run Azure Power shell commands from Linux - Ultimate Guide:

Install Powershell on linux

# Update the list of packages
sudo apt-get update

# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
@alidevhere
alidevhere / gist:247b4f23ba0c5b887fa25c92196db9d9
Created December 15, 2021 04:31
Connect To University Wifi from Ubuntu 20.04 LTS
Click on the wireless icon located in the upper right task bar.
Select 'eduroam'
In the Security field, select 'WPA & WPA2 Enterprise'
In the Authentication field, select 'Protected EAP (PEAP)'
Leave the Anonymous Identity field blank
The CA certificate field should be set to 'None'
The check box 'No CA certificate is required' should be checked
The PEAP version field should be set to 'Automatic'
The Inner Authentication field should be set to 'MSCHAPV2'
In the Username field, enter your username@rose-hulman.edu
@miguelmota
miguelmota / struct_custom_unmarshal.go
Created March 15, 2018 04:12
Golang custom struct unmarshal function example
package main
import (
"encoding/json"
"fmt"
"log"
"time"
)
type MyStruct struct {
@heyimalex
heyimalex / sqlmap.go
Last active April 6, 2024 14:25
Functions for querying directly into map[string]interface{}
// Package sqlmap provides functions for querying directly into
// map[string]interface{}.
//
// In developing really simple api endpoints, I found the boilerplate needed
// to take the results of a database query and output them as JSON to be
// really fucking annoying; make a custom struct, scan into that struct, if
// there are multiple rows do the whole rows.Next() song and dance, and if
// anything changes update the three spots each column of the result is now
// dependent on. Even when using libraries like sqlx, there's still a lot of
// extraneous code that needs to be written.
@mariocesar
mariocesar / admin.py
Last active December 28, 2023 19:17
Django admin decorator to create a confirmation form action, like the default delete action works
from .models import Post, Category
from .decorators import action_form
class PostCategoryForm(forms.Form):
title = 'Update category for the selected posts'
myfile = forms.FileField()
category = forms.ModelChoiceField(queryset=Category.objects.all())
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@mattes
mattes / check.go
Last active May 3, 2024 22:20
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@Soulou
Soulou / hijackhttps.go
Created July 21, 2013 10:45
I was looking to do HTTPS socket hijacking, here is the way to do ! The link between client and server are completely encrpted. Keywords : HTTPS TCP Socket Hijacking Golang
package main
import (
"crypto/tls"
"fmt"
"net"
"net/http"
"net/http/httputil"
"time"
)