Skip to content

Instantly share code, notes, and snippets.

@dafma
dafma / main.dart
Created August 31, 2020 01:49 — forked from ffeu/main.dart
Flutter Main Example with StreamBuilder
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
@dafma
dafma / (view)formprofileanduser.py
Created April 9, 2018 18:36
custom create user and profile with @Reciver
def crearempresa(request):
field_ejecutivo = Profile.objects.filter(tipo_usuario='ejecutivo')
if request.method == 'POST':
user_form = UserEmpresaForm(data=request.POST or None)
if user_form.is_valid():
user = user_form.save()
user.refresh_from_db()
user.profile.rfc = user_form.cleaned_data.get('rfc')
user.profile.tipo_usuario = 'empresa'
ALTER FUNCTION [dbo].[fnCFDFlexCadenaOriginalTFDI]
(
@Modulo varchar(5),
@ModuloID int
)
/*
declare @valor varchar(1000)
exec @valor=fnCFDFlexCadenaOriginalTFDI 'VTAS',884727
ALTER PROCEDURE [dbo].[spCFDFlexTextoQRCode]
(
@Modulo varchar(5),
@ModuloID int
)
--exec spCFDFlexTExtoQRCode 'VTAS', 891160
AS BEGIN
""" Guarda un dato como xml
xml = "<myxmldata/>".encode()
f = open("myxmlfile.xml", "wb")
f.write(xml)
f.close()
"""
import pyodbc
""" Guarda un dato como xml
xml = "<myxmldata/>".encode()
f = open("myxmlfile.xml", "wb")
f.write(xml)
f.close()
"""
import pyodbc
/*
if (select count(distinct fechaentrega) from CompraD where id=47024288) >1
begin
print 'mas de dos'
end
else
print 'nel'
select distinct FechaEntrega from CompraD where id=47024685
update compraD set FechaEntrega='19/04/2017' where id=47024685 and renglon=2048
@dafma
dafma / buscarCampoDentrounaTablaEnBaseDeDatos.sql
Created October 24, 2017 22:31
buscar un campo dentro de todas las tablas en una base de datos
select sysobjects.name,sysobjects.xtype,syscolumns.*
from syscolumns, sysobjects
where syscolumns.id = sysobjects.id and
sysobjects.xtype = 'U' and
syscolumns.name = 'Moneda'
order by sysobjects.name
@dafma
dafma / PythonProximoMartesdeUnaFecha.py
Created September 7, 2017 17:34
el próximo martes a partir de una fecha
import datetime
d = datetime.date(2017, 9, 9)
def next_weekday(d, weekday):
days_ahead = weekday - d.weekday()
if days_ahead <= 0:
days_ahead += 7
return d + datetime.timedelta(days_ahead)
@dafma
dafma / sumardiasPython.py
Created September 7, 2017 17:13
Sumar dias a una fecha
from datetime import datetime, timedelta
s = '2004/03/30'
date = datetime.strptime(s, "%Y/%m/%d")
modified_date = date + timedelta(days=5)
print(modified_date)