This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chunkSizeInBytes := 1048576 | |
chunksDir := "/path/to/uploads/temp/3203610240-WildifeTactics" | |
/* | |
Generate an empty file | |
*/ | |
f, err := os.Create("testfile.mp4") | |
if err != nil { | |
fmt.Printf("Error: %s", err) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ResumableUpload handles reumable uploads | |
func ResumableUpload(w http.ResponseWriter, r *http.Request) { | |
tempFolder := "/path/to/uploads/temp/" | |
switch r.Method { | |
case "GET": | |
resumableIdentifier, _ := r.URL.Query()["resumableIdentifier"] | |
resumableChunkNumber, _ := r.URL.Query()["resumableChunkNumber"] | |
path := fmt.Sprintf("%s%s", tempFolder, resumableIdentifier[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="resumable.js"></script> | |
<script> | |
var r = new Resumable({ | |
target:'http://localhost:8080/upload', | |
}); | |
r.assignBrowse(document.getElementById('upload-area')); | |
// Resumable.js isn't supported, fall back on a different method | |
if(!r.support) location.href = '/some-old-crappy-uploader'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
.resume-upload{ | |
width: 60%; | |
height: 200px; | |
background: skyblue; | |
margin: 40 auto; | |
border: 1px dashed black; | |
} | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MobileTokenBaseSerializer(serializers.Serializer): | |
verification_code=serializers.CharField() | |
def validate_verification_code(self,value): | |
if not MobileToken.objects.filter(verification_code=value).exists(): | |
raise serializers.ValidationError("The token provided does not exist") | |
elif MobileToken.objects.filter(verification_code=value).first().is_used: | |
raise serializers.ValidationError("The token provided is used") | |
return value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MobileAuthView(generics.GenericAPIView): | |
permission_classes = () | |
authentication_classes = () | |
serializer_class=MobileAuthSerializer | |
def post(self, request, *args, **kwargs): | |
serializer = self.get_serializer(data=request.data) | |
if serializer.is_valid(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MobileToken(models.Model): | |
verification_code=models.CharField(max_length=225) | |
user=models.ForeignKey(settings.AUTH_USER_MODEL, related_name="mobile_tokens",on_delete=models.CASCADE) | |
phone_number=models.CharField(max_length=225) | |
is_used=models.BooleanField(default=False) | |
created = models.DateTimeField("Created on", auto_now_add=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MobileAuthSerializer(serializers.Serializer): | |
phone_number=serializers.CharField(required=True) | |
def save(self): | |
#Retrieve the user with this mobile number or create a user instance with that phone number | |
try: | |
user=User.objects.get(mobile=self.validated_data['phone_number']) | |
except Exception as e: | |
user=User.objects.create(mobile=self.validated_data['phone_number'],email=self.validated_data['phone_number']) | |
#Generate the users token and send it out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$iframe_string = '<iframe width="100%" height="315" src="https://www.youtube.com/embed/-XC6r9SIQfo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'; | |
preg_match('/src="([^"]+)"/', $iframe_string, $match); | |
/*Output all the matches by the expression*/ | |
print_r($match); | |
/*Get the index of the array*/ | |
$url = $match[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$orders = Order::join('assignments', 'orders.active_assignment', '=', 'assignments.id'); | |
$orders->join('users', 'assignments.user_id', '=', 'users.id'); | |
$orders->leftJoin('bargains', 'bargains.order_id', '=', 'orders.id'); | |
$orders->doesntHave('payment'); | |
$orders->where('orders.status',4); | |
$orders->select(['orders.id','bargains.order_id','users.id as user_id','orders.order_no','orders.salary','users.name',DB::raw('SUM(bargains.amount) As bargains_sum, (SUM(bargains.amount)+orders.salary) as total')]); | |
$orders->groupBy(['orders.id']); | |
$result = $orders->get(); | |
/* |
NewerOlder